32 #ifndef MCKL_INTERNAL_TRAITS_HPP 33 #define MCKL_INTERNAL_TRAITS_HPP 37 #include <type_traits> 39 #define MCKL_DEFINE_TYPE_DISPATCH_TRAIT(Outer, Inner, Default) \ 40 template <typename T> \ 43 namespace internal { \ 45 template <typename T> \ 46 class Has##Outer##Impl \ 54 template <typename U> \ 55 static char test(typename U::Inner *); \ 57 template <typename U> \ 58 static char2 test(...); \ 61 static constexpr bool value = \ 62 sizeof(test<T>(nullptr)) == sizeof(char); \ 65 template <typename T> \ 67 : public std::integral_constant<bool, Has##Outer##Impl<T>::value> \ 71 template <typename T, bool> \ 72 class Outer##Dispatch; \ 74 template <typename T> \ 75 class Outer##Dispatch<T, false> \ 78 using type = Default; \ 81 template <typename T> \ 82 class Outer##Dispatch<T, true> \ 85 using type = typename T::Inner; \ 90 template <typename T> \ 94 static constexpr bool value = internal::Has##Outer<T>::value; \ 95 using type = typename internal::Outer##Dispatch<T, value>::type; \ 98 template <typename T> \ 99 using Outer = typename Outer##Trait<T>::type; 101 #define MCKL_DEFINE_TYPE_TEMPLATE_DISPATCH_TRAIT(Outer, Inner, Default) \ 102 template <typename T> \ 103 class Outer##Trait; \ 105 namespace internal { \ 107 template <typename T> \ 108 class Has##Outer##Impl \ 116 template <typename U> \ 117 static char test(typename U::template Inner<T> *); \ 119 template <typename U> \ 120 static char2 test(...); \ 123 static constexpr bool value = \ 124 sizeof(test<T>(nullptr)) == sizeof(char); \ 127 template <typename T> \ 129 : public std::integral_constant<bool, Has##Outer##Impl<T>::value> \ 133 template <typename T, bool> \ 134 class Outer##Dispatch; \ 136 template <typename T> \ 137 class Outer##Dispatch<T, false> \ 140 using type = Default<T>; \ 143 template <typename T> \ 144 class Outer##Dispatch<T, true> \ 147 using type = typename T::template Inner<T>; \ 151 template <typename T> \ 155 static constexpr bool value = internal::Has##Outer<T>::value; \ 156 using type = typename internal::Outer##Dispatch<T, value>::type; \ 159 template <typename T> \ 160 using Outer = typename Outer##Trait<T>::type; 170 template <
typename T, std::
size_t K = 1>
172 :
public std::integral_constant<std::size_t,
173 8192 / (sizeof(T) * K) == 0 ? 1 : 8192 / (sizeof(T) * K)>
177 template <
typename T>
179 std::is_same<typename std::remove_cv<T>::type,
float>::value ||
180 std::is_same<typename std::remove_cv<T>::type,
double>::value>;
182 template <
typename T,
typename RNGType,
183 typename KeyType =
typename RNGType::result_type>
185 std::is_class<T>::value && !std::is_convertible<T, RNGType>::value &&
186 !std::is_convertible<T, typename RNGType::result_type>::value &&
187 !std::is_convertible<T, KeyType>::value>;
193 #endif // MCKL_INTERNAL_TRAITS_HPP std::integral_constant< bool, std::is_same< typename std::remove_cv< T >::type, float >::value||std::is_same< typename std::remove_cv< T >::type, double >::value > is_blas_floating_point
#define MCKL_DEFINE_TYPE_DISPATCH_TRAIT(Outer, Inner, Default)
std::integral_constant< bool, std::is_class< T >::value &&!std::is_convertible< T, RNGType >::value &&!std::is_convertible< T, typename RNGType::result_type >::value &&!std::is_convertible< T, KeyType >::value > is_seed_seq
typename SizeTypeTrait< T >::type SizeType