File indexing completed on 2025-01-31 10:25:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #ifndef VC_TRAITS_TYPE_TRAITS_H_
0029 #define VC_TRAITS_TYPE_TRAITS_H_
0030
0031 #include <type_traits>
0032 #include "decay.h"
0033 #include "has_no_allocated_data.h"
0034 #include "has_contiguous_storage.h"
0035 #include "is_functor_argument_immutable.h"
0036 #include "is_output_iterator.h"
0037 #include "is_index_sequence.h"
0038 #include "is_implicit_cast_allowed.h"
0039
0040 namespace Vc_VERSIONED_NAMESPACE
0041 {
0042
0043 struct enable_if_default_type
0044 {
0045 constexpr enable_if_default_type() {}
0046 };
0047 static constexpr enable_if_default_type nullarg;
0048 template <bool Test, typename T = enable_if_default_type> using enable_if = typename std::enable_if<Test, T>::type;
0049
0050 template <bool B, class T, class F>
0051 using conditional_t = typename std::conditional<B, T, F>::type;
0052
0053 template <class T>
0054 using remove_cvref_t =
0055 typename std::remove_cv<typename std::remove_reference<T>::type>::type;
0056
0057 namespace Traits
0058 {
0059 #include "has_subscript_operator.h"
0060 #include "has_multiply_operator.h"
0061 #include "has_addition_operator.h"
0062 #include "has_equality_operator.h"
0063
0064 template<typename T> struct is_valid_vector_argument : public std::false_type {};
0065
0066 template <> struct is_valid_vector_argument<double> : public std::true_type {};
0067 template <> struct is_valid_vector_argument<float> : public std::true_type {};
0068 template <> struct is_valid_vector_argument<int> : public std::true_type {};
0069 template <> struct is_valid_vector_argument<unsigned int> : public std::true_type {};
0070 template <> struct is_valid_vector_argument<short> : public std::true_type {};
0071 template <> struct is_valid_vector_argument<unsigned short> : public std::true_type {};
0072
0073 template<typename T> struct is_simd_mask_internal : public std::false_type {};
0074 template<typename T> struct is_simd_vector_internal : public std::false_type {};
0075 template<typename T> struct is_simdarray_internal : public std::false_type {};
0076 template<typename T> struct is_simd_mask_array_internal : public std::false_type {};
0077 template<typename T> struct is_loadstoreflag_internal : public std::false_type {};
0078
0079 template <typename T, bool = is_simd_vector_internal<T>::value> struct is_integral_internal;
0080 template <typename T, bool = is_simd_vector_internal<T>::value> struct is_floating_point_internal;
0081 template <typename T, bool = is_simd_vector_internal<T>::value> struct is_signed_internal;
0082 template <typename T, bool = is_simd_vector_internal<T>::value> struct is_unsigned_internal;
0083
0084 template <typename T> struct is_integral_internal <T, false> : public std::is_integral <T> {};
0085 template <typename T> struct is_floating_point_internal<T, false> : public std::is_floating_point<T> {};
0086 template <typename T> struct is_signed_internal <T, false> : public std::is_signed <T> {};
0087 template <typename T> struct is_unsigned_internal <T, false> : public std::is_unsigned <T> {};
0088
0089 template <typename V> struct is_integral_internal <V, true> : public std::is_integral <typename V::EntryType> {};
0090 template <typename V> struct is_floating_point_internal<V, true> : public std::is_floating_point<typename V::EntryType> {};
0091 template <typename V> struct is_signed_internal <V, true> : public std::is_signed <typename V::EntryType> {};
0092 template <typename V> struct is_unsigned_internal <V, true> : public std::is_unsigned <typename V::EntryType> {};
0093
0094 template <typename T>
0095 struct is_arithmetic_internal
0096 : public std::integral_constant<
0097 bool,
0098 (is_floating_point_internal<T>::value || is_integral_internal<T>::value)>
0099 {
0100 };
0101
0102 template <class T, class = void>
0103 struct vector_size_internal : std::integral_constant<std::size_t, 0> {
0104 };
0105 template <class T>
0106 struct vector_size_internal<T, decltype((void)(T::size() > 0))>
0107 : std::integral_constant<std::size_t, T::size()> {
0108 };
0109
0110
0111
0112
0113
0114
0115
0116 template <typename T>
0117 struct is_simd_mask : public std::integral_constant<bool,
0118 (is_simd_mask_internal<decay<T>>::value ||
0119 is_simd_mask_array_internal<decay<T>>::value)>
0120 {
0121 };
0122
0123
0124
0125
0126
0127 template <typename T>
0128 struct is_simd_vector
0129 : public std::integral_constant<bool,
0130 (is_simd_vector_internal<decay<T>>::value ||
0131 is_simdarray_internal<decay<T>>::value)>
0132 {
0133 };
0134
0135
0136 template <typename T>
0137 struct isSimdArray : public is_simdarray_internal<decay<T>>
0138 {
0139 };
0140
0141
0142 template <typename T>
0143 struct isSimdMaskArray : public is_simd_mask_array_internal<decay<T>>
0144 {
0145 };
0146
0147
0148 template <typename T> struct is_load_store_flag : public is_loadstoreflag_internal<decay<T>> {};
0149
0150
0151 template <typename T> struct is_atomic_simdarray_internal : public std::false_type {};
0152 template <typename T> using isAtomicSimdArray = is_atomic_simdarray_internal<decay<T>>;
0153
0154
0155 template <typename T> struct is_atomic_simd_mask_array_internal : public std::false_type {};
0156 template <typename T> using isAtomicSimdMaskArray = is_atomic_simd_mask_array_internal<decay<T>>;
0157
0158
0159
0160
0161
0162 template <typename T> struct simd_vector_size : public vector_size_internal<decay<T>> {};
0163
0164 template <typename T> struct is_integral : public is_integral_internal<decay<T>> {};
0165 template <typename T> struct is_floating_point : public is_floating_point_internal<decay<T>> {};
0166 template <typename T> struct is_arithmetic : public is_arithmetic_internal<decay<T>> {};
0167 template <typename T> struct is_signed : public is_signed_internal<decay<T>> {};
0168 template <typename T> struct is_unsigned : public is_unsigned_internal<decay<T>> {};
0169
0170 template <typename T, bool IsSimdVector> struct scalar_type_internal { using type = T; };
0171 template <typename T> struct scalar_type_internal<T, true> { using type = typename T::EntryType; };
0172 template <typename T> using scalar_type = typename scalar_type_internal<decay<T>, is_simd_vector<T>::value>::type;
0173
0174 }
0175 }
0176
0177 #include "entry_type_of.h"
0178
0179 #endif