Warning, file /include/Vc/common/detail.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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_COMMON_DETAIL_H_
0029 #define VC_COMMON_DETAIL_H_
0030
0031 #include <vector>
0032
0033 #include "macros.h"
0034
0035 namespace Vc_VERSIONED_NAMESPACE
0036 {
0037 namespace Common
0038 {
0039
0040
0041 template <typename IV>
0042 Vc_INTRINSIC enable_if<(Traits::is_simd_vector<IV>::value &&
0043 sizeof(typename IV::EntryType) >= sizeof(int)),
0044 const IV &>
0045 convertIndexVector(const IV &indexVector)
0046 {
0047 return indexVector;
0048 }
0049
0050
0051
0052 template <typename IV>
0053 Vc_INTRINSIC enable_if<(Traits::is_simd_vector<IV>::value &&
0054 sizeof(typename IV::EntryType) < sizeof(int)),
0055 fixed_size_simd<int, IV::Size>>
0056 convertIndexVector(const IV &indexVector)
0057 {
0058 return static_cast<fixed_size_simd<int, IV::Size>>(indexVector);
0059 }
0060
0061
0062 template <class T> using promoted_type = decltype(std::declval<T>() + 1);
0063
0064
0065
0066 template <typename T, std::size_t N>
0067 Vc_INTRINSIC enable_if<std::is_integral<T>::value, fixed_size_simd<promoted_type<T>, N>>
0068 convertIndexVector(const std::array<T, N> &indexVector)
0069 {
0070 return fixed_size_simd<promoted_type<T>, N>{std::addressof(indexVector[0]),
0071 Vc::Unaligned};
0072 }
0073 template <typename T, std::size_t N>
0074 Vc_INTRINSIC enable_if<std::is_integral<T>::value, fixed_size_simd<promoted_type<T>, N>>
0075 convertIndexVector(const Vc::array<T, N> &indexVector)
0076 {
0077 return fixed_size_simd<promoted_type<T>, N>{std::addressof(indexVector[0]),
0078 Vc::Unaligned};
0079 }
0080 template <typename T, std::size_t N>
0081 Vc_INTRINSIC enable_if<std::is_integral<T>::value, fixed_size_simd<promoted_type<T>, N>>
0082 convertIndexVector(const T (&indexVector)[N])
0083 {
0084 return fixed_size_simd<promoted_type<T>, N>{std::addressof(indexVector[0]),
0085 Vc::Unaligned};
0086 }
0087
0088
0089
0090 #ifndef Vc_MSVC
0091
0092
0093 template <class T>
0094 enable_if<std::is_pointer<T>::value, void> convertIndexVector(T indexVector) = delete;
0095 #endif
0096
0097
0098
0099 template <typename T>
0100 Vc_INTRINSIC std::vector<promoted_type<T>> convertIndexVector(
0101 const std::initializer_list<T> &indexVector)
0102 {
0103 return {begin(indexVector), end(indexVector)};
0104 }
0105
0106
0107 template <typename T>
0108 Vc_INTRINSIC
0109 enable_if<(std::is_integral<T>::value && sizeof(T) >= sizeof(int)), std::vector<T>>
0110 convertIndexVector(const std::vector<T> &indexVector)
0111 {
0112 return indexVector;
0113 }
0114 template <typename T>
0115 Vc_INTRINSIC enable_if<(std::is_integral<T>::value && sizeof(T) < sizeof(int)),
0116 std::vector<promoted_type<T>>>
0117 convertIndexVector(const std::vector<T> &indexVector)
0118 {
0119 return {std::begin(indexVector), std::end(indexVector)};
0120 }
0121
0122 template <class T,
0123 class = enable_if<
0124 (!std::is_pointer<T>::value && !Traits::is_simd_vector<T>::value &&
0125 !std::is_lvalue_reference<decltype(std::declval<const T &>()[0])>::value)>>
0126 Vc_INTRINSIC const T &convertIndexVector(const T &i)
0127 {
0128 return i;
0129 }
0130
0131
0132 }
0133 }
0134
0135 #endif
0136
0137