2#ifndef RIVET_TypeTraits_HH
3#define RIVET_TypeTraits_HH
29 struct TypeTraits<const U&> {
30 using ArgType = RefType;
34 struct TypeTraits<const U*> {
35 using ArgType = PtrType;
39 struct TypeIdentity {
using type = T; };
44 using sign_if_integral = std::conditional_t<(std::is_integral_v<T> && !std::is_same_v<T,bool>),
45 std::make_signed<T>, TypeIdentity<T>>;
48 using sign_if_integral_t =
typename sign_if_integral<T>::type;
51 template<
typename... Args>
52 using all_unsigned = std::conjunction<std::is_unsigned<Args>...>;
55 template<
typename... Args>
56 using signed_if_mixed_t = std::conditional_t<all_unsigned<Args...>::value,
57 std::common_type_t<Args...>,
58 std::common_type_t<sign_if_integral_t<Args>...>>;
62 template <
typename T,
typename=
void>
63 struct Derefable : std::false_type {};
66 struct Derefable<T,
std::void_t< decltype(*std::declval<T>())> > : std::true_type {};
72 template<
typename T,
typename =
void>
73 struct Iterable : std::false_type { };
76 struct Iterable<T,
std::void_t<std::decay_t<decltype(std::begin(std::declval<const T&>()))>,
77 std::decay_t<decltype(std::end(std::declval<const T&>()))>>> : std::true_type { };
80 inline constexpr bool is_iterable_v = Iterable<T>::value;
85 using isIterable = std::enable_if_t<Iterable<T>::value>;
89 template<
typename T,
typename =
void>
90 struct CIterable : std::false_type { };
93 struct CIterable<T,
std::void_t<decltype(std::declval<typename std::decay_t<T>::const_iterator>())>> : std::true_type { };
96 inline constexpr bool is_citerable_v = CIterable<T>::value;
100 template<
typename... Args>
101 using isCIterable = std::enable_if_t<(CIterable<Args>::value && ...)>;
105 struct isCString : std::false_type { };
108 struct isCString<char[]> : std::true_type { };
111 struct isCString<char[N]> : std::true_type { };
113 template <
typename T>
114 inline constexpr bool is_cstring_v = isCString<T>::value;
118 template<
typename T,
typename =
void>
119 struct hasBinning : std::false_type { };
122 struct hasBinning<T,
std::void_t<decltype(std::declval<T>().binning())>> : std::true_type { };
126 template<
typename T,
typename =
void>
127 struct isFillable : std::false_type { };
130 struct isFillable<T,
std::void_t<decltype(typename T::FillType{})>> : std::true_type { };
134 template<
typename T,
typename U,
typename =
void>
135 struct isArgumentOf : std::false_type { };
137 template<
typename T,
typename U>
138 struct isArgumentOf<T, U,
std::void_t<decltype(T(std::declval<U>()))>>
139 : std::true_type { };
142 template <
typename T,
typename... Us>
143 using allArgumentsOf =
typename std::conjunction<isArgumentOf<T, Us>...>;
146 template <
typename T,
typename=
void>
147 struct HasXYZ : std::false_type {};
148 template <
typename T>
149 struct HasXYZ<T,
std::void_t< decltype(std::declval<T>().x() + std::declval<T>().y() +
150 std::declval<T>().z())> > : std::true_type {};
154 template <
typename T,
typename=
void>
155 struct HasXYZT : std::false_type {};
156 template <
typename T>
157 struct HasXYZT<T,
std::void_t< decltype(std::declval<T>().x() + std::declval<T>().y() +
158 std::declval<T>().z() + std::declval<T>().t())> > : std::true_type {};
Definition MC_CENT_PPB_Projections.hh:10