28 #ifndef Vc_CURRENT_CLASS_NAME 29 #error "incorrect use of common/gatherinterface.h: Vc_CURRENT_CLASS_NAME must be defined to the current class name for declaring constructors." 55 template <
typename MT,
typename IT>
56 inline void gatherImplementation(
const MT *mem,
const IT &indexes);
62 template <
typename MT,
typename IT>
63 inline void gatherImplementation(
const MT *mem,
const IT &indexes, MaskArgument mask);
73 template <typename IT, typename = enable_if<std::is_pointer<IT>::value ||
74 Traits::is_simd_vector<IT>::value>>
75 static Vc_INTRINSIC
const IT &adjustIndexParameter(
const IT &indexes)
93 !std::is_pointer<IT>::value && !Traits::is_simd_vector<IT>::value &&
94 std::is_lvalue_reference<decltype(std::declval<const IT &>()[0])>::value>>
95 static Vc_INTRINSIC decltype(std::addressof(std::declval<const IT &>()[0]))
96 adjustIndexParameter(const IT &i)
98 return std::addressof(i[0]);
108 template <
typename IT>
109 static Vc_INTRINSIC enable_if<
110 !std::is_pointer<IT>::value && !Traits::is_simd_vector<IT>::value &&
111 !std::is_lvalue_reference<decltype(std::declval<const IT &>()[0])>::value,
113 adjustIndexParameter(
const IT &i)
119 #define Vc_ASSERT_GATHER_PARAMETER_TYPES_ \ 121 std::is_convertible<MT, EntryType>::value, \ 122 "The memory pointer needs to point to a type that can be converted to the " \ 123 "EntryType of this SIMD vector type."); \ 125 Vc::Traits::has_subscript_operator<IT>::value, \ 126 "The indexes argument must be a type that implements the subscript operator."); \ 128 !Traits::is_simd_vector<IT>::value || \ 129 Traits::simd_vector_size<IT>::value >= Size, \ 130 "If you use a SIMD vector for the indexes parameter, the index vector must " \ 131 "have at least as many entries as this SIMD vector."); \ 133 !std::is_array<T>::value || \ 134 (std::rank<T>::value == 1 && \ 135 (std::extent<T>::value == 0 || std::extent<T>::value >= Size)), \ 136 "If you use a simple array for the indexes parameter, the array must have " \ 137 "at least as many entries as this SIMD vector.") 192 template <
typename MT,
typename IT,
193 typename = enable_if<Traits::has_subscript_operator<IT>::value>>
194 Vc_INTRINSIC Vc_CURRENT_CLASS_NAME(
const MT *mem,
const IT &indexes)
196 Vc_ASSERT_GATHER_PARAMETER_TYPES_;
197 gatherImplementation(mem, adjustIndexParameter(indexes));
201 template <
typename MT,
typename IT,
202 typename = enable_if<Vc::Traits::has_subscript_operator<IT>::value>>
203 Vc_INTRINSIC Vc_CURRENT_CLASS_NAME(
const MT *mem,
const IT &indexes,
206 Vc_ASSERT_GATHER_PARAMETER_TYPES_;
207 gatherImplementation(mem, adjustIndexParameter(indexes), mask);
211 template <
typename MT,
typename IT,
212 typename = enable_if<Vc::Traits::has_subscript_operator<IT>::value>>
213 Vc_INTRINSIC
void gather(
const MT *mem,
const IT &indexes)
215 Vc_ASSERT_GATHER_PARAMETER_TYPES_;
216 gatherImplementation(mem, adjustIndexParameter(indexes));
220 template <
typename MT,
typename IT,
221 typename = enable_if<Vc::Traits::has_subscript_operator<IT>::value>>
222 Vc_INTRINSIC
void gather(
const MT *mem,
const IT &indexes, MaskArgument mask)
224 Vc_ASSERT_GATHER_PARAMETER_TYPES_;
225 gatherImplementation(mem, adjustIndexParameter(indexes), mask);
229 #include "gatherinterface_deprecated.h" 237 template <
typename MT,
typename IT>
239 Vc_INTRINSIC
void gather(
const Common::GatherArguments<MT, IT> &args)
241 gather(args.address, adjustIndexParameter(args.indexes));
244 template <
typename MT,
typename IT>
245 Vc_INTRINSIC
void gather(
const Common::GatherArguments<MT, IT> &args, MaskArgument mask)
247 gather(args.address, adjustIndexParameter(args.indexes), mask);
251 #undef Vc_ASSERT_GATHER_PARAMETER_TYPES_