File indexing completed on 2026-11-07 10:37:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef XSIMD_TYPE_TRAITS_HPP
0013 #define XSIMD_TYPE_TRAITS_HPP
0014
0015 #include <cstddef>
0016 #include <cstdint>
0017 #include <type_traits>
0018
0019 namespace xsimd
0020 {
0021 namespace detail
0022 {
0023 template <std::size_t S>
0024 struct sized_num_types;
0025
0026 template <>
0027 struct sized_num_types<1>
0028 {
0029 using signed_type = std::int8_t;
0030 using unsigned_type = std::uint8_t;
0031 using floating_point_type = void;
0032 };
0033
0034 template <>
0035 struct sized_num_types<2>
0036 {
0037 using signed_type = std::int16_t;
0038 using unsigned_type = std::uint16_t;
0039 using floating_point_type = void;
0040 };
0041
0042 template <>
0043 struct sized_num_types<4>
0044 {
0045 using signed_type = std::int32_t;
0046 using unsigned_type = std::uint32_t;
0047 using floating_point_type = float;
0048 };
0049
0050 template <>
0051 struct sized_num_types<8>
0052 {
0053 using signed_type = std::int64_t;
0054 using unsigned_type = std::uint64_t;
0055 using floating_point_type = double;
0056 };
0057 }
0058
0059
0060
0061
0062
0063
0064
0065
0066 template <std::size_t S>
0067 using sized_int_t = typename detail::sized_num_types<S>::signed_type;
0068
0069
0070
0071
0072
0073
0074
0075
0076 template <std::size_t S>
0077 using sized_uint_t = typename detail::sized_num_types<S>::unsigned_type;
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087 template <std::size_t S>
0088 using sized_fp_t = typename detail::sized_num_types<S>::floating_point_type;
0089
0090 namespace detail
0091 {
0092 template <typename T, std::size_t factor, typename = void>
0093 struct remap_num
0094 {
0095 using type = T;
0096 };
0097
0098 template <typename T, std::size_t factor>
0099 struct remap_num<T, factor, std::enable_if_t<std::is_floating_point<T>::value>>
0100 {
0101 using type = xsimd::sized_fp_t<sizeof(T) * factor>;
0102 };
0103
0104 template <typename T, std::size_t factor>
0105 struct remap_num<T, factor, std::enable_if_t<!std::is_floating_point<T>::value && std::is_signed<T>::value>>
0106 {
0107 using type = xsimd::sized_int_t<sizeof(T) * factor>;
0108 };
0109
0110 template <typename T, std::size_t factor>
0111 struct remap_num<T, factor, std::enable_if_t<!std::is_floating_point<T>::value && std::is_unsigned<T>::value>>
0112 {
0113 using type = xsimd::sized_uint_t<sizeof(T) * factor>;
0114 };
0115 }
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129 template <typename T>
0130 using map_to_sized_type_t = typename detail::remap_num<T, 1>::type;
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141 template <typename T>
0142 using widen_t = typename detail::remap_num<T, 2>::type;
0143 }
0144
0145 #endif