21 #ifndef PLAYRHO_COMMON_TEMPLATES_HPP
22 #define PLAYRHO_COMMON_TEMPLATES_HPP
31 #include <type_traits>
59 template<
class T,
class =
void>
65 decltype(begin(std::declval<T>())),
66 decltype(end(std::declval<T>())),
67 decltype(++std::declval<decltype(begin(std::declval<T&>()))&>()),
68 decltype(*begin(std::declval<T>()))
77 return arg.max_size();
90 static auto Data(T& v)
92 using ::playrho::data;
99 static auto Size(T& v)
111 template <
typename T>
114 static_assert(
sizeof(T) == 0,
"No available specialization");
118 template <
typename T>
131 return value == value;
140 return std::numeric_limits<float>::signaling_NaN();
147 return std::numeric_limits<double>::signaling_NaN();
154 return std::numeric_limits<long double>::signaling_NaN();
161 return static_cast<std::size_t
>(-1);
170 return value != GetInvalid<std::size_t>();
238 template <
typename T>
248 template <
typename T>
253 return typeid(T).name();
274 return "long double";
280 template<
class T1,
class T2,
class =
void>
284 template<
class T1,
class T2>
288 template<
class T1,
class T2,
class =
void>
292 template<
class T1,
class T2>
296 template<
class T1,
class T2 = T1,
class =
void>
300 template<
class T1,
class T2>
301 struct IsAddable<T1, T2, detail::
VoidT<decltype(T1{} + T2{})> >: std::true_type {};
304 template<
class T1,
class T2,
class =
void>
308 template<
class T1,
class T2>
312 template<
class T1,
class T2,
class =
void>
316 template<
class T1,
class T2>
322 template<
class T,
class =
void>
328 decltype(T{} + T{}), decltype(T{} - T{}), decltype(T{} * T{}), decltype(T{} / T{})
329 > >: std::true_type {};
339 template <
typename T,
typename Tuple>
346 template <
typename T>
347 struct HasType<T, std::tuple<>> : std::false_type {};
353 template <
typename T,
typename... Ts>
354 struct HasType<T, std::tuple<T, Ts...>> : std::true_type {};
360 template <
typename T,
typename U,
typename... Ts>
369 template <
typename T,
typename Tuple>
384 template <
typename T>
392 using ElementType = decltype(*begin(lhs));
393 return std::lexicographical_compare(begin(lhs), end(lhs), begin(rhs), end(rhs),
394 less<ElementType>{});
402 template <
typename T>
410 using ElementType = decltype(*begin(lhs));
411 return std::lexicographical_compare(begin(lhs), end(lhs), begin(rhs), end(rhs),
412 greater<ElementType>{});
420 template <
typename T>
430 using ElementType = decltype(*begin(lhs));
431 const auto lhsEnd = end(lhs);
432 const auto diff = mismatch(begin(lhs), lhsEnd, begin(rhs), end(rhs));
441 template <
typename T>
451 using ElementType = decltype(*begin(lhs));
452 const auto lhsEnd = end(lhs);
453 const auto diff = mismatch(begin(lhs), lhsEnd, begin(rhs), end(rhs));
454 return (
get<0>(diff) == lhsEnd) || greater<ElementType>{}(*
get<0>(diff), *
get<1>(diff));
460 #endif // PLAYRHO_COMMON_TEMPLATES_HPP