29 #ifndef Vc_CURRENT_CLASS_NAME
30 #error "incorrect use of common/gatherinterface.h: Vc_CURRENT_CLASS_NAME must be defined to the current class name for declaring constructors."
56 template <
typename MT,
typename IT>
57 inline void gatherImplementation(
const MT *mem, IT &&indexes);
63 template <
typename MT,
typename IT>
64 inline void gatherImplementation(
const MT *mem, IT &&indexes, MaskArgument mask);
74 template <typename IT, typename = enable_if<std::is_pointer<IT>::value ||
75 Traits::is_simd_vector<IT>::value>>
76 static Vc_INTRINSIC IT adjustIndexParameter(IT &&indexes)
78 return std::forward<IT>(indexes);
91 template <
typename IT,
93 !std::is_pointer<IT>::value && !Traits::is_simd_vector<IT>::value &&
94 std::is_lvalue_reference<decltype(std::declval<IT>()[0])>::value>>
95 static Vc_INTRINSIC decltype(std::addressof(std::declval<IT>()[0]))
96 adjustIndexParameter(IT &&i)
98 return std::addressof(i[0]);
108 template <
typename IT>
110 enable_if<!std::is_pointer<IT>::value && !Traits::is_simd_vector<IT>::value &&
111 !std::is_lvalue_reference<decltype(std::declval<IT>()[0])>::value,
113 adjustIndexParameter(IT &&i)
115 return std::forward<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.")
181 template <
typename MT,
typename IT,
182 typename = enable_if<Traits::has_subscript_operator<IT>::value>>
183 Vc_INTRINSIC Vc_CURRENT_CLASS_NAME(
const MT *mem, IT &&indexes)
185 Vc_ASSERT_GATHER_PARAMETER_TYPES_;
186 gatherImplementation(mem, adjustIndexParameter(std::forward<IT>(indexes)));
190 template <
typename MT,
typename IT,
191 typename = enable_if<Vc::Traits::has_subscript_operator<IT>::value>>
192 Vc_INTRINSIC Vc_CURRENT_CLASS_NAME(
const MT *mem, IT &&indexes, MaskArgument mask)
194 Vc_ASSERT_GATHER_PARAMETER_TYPES_;
195 gatherImplementation(mem, adjustIndexParameter(std::forward<IT>(indexes)), mask);
199 template <
typename MT,
201 typename = enable_if<Vc::Traits::has_subscript_operator<IT>::value>>
202 Vc_INTRINSIC
void gather(
const MT *mem, IT &&indexes)
204 Vc_ASSERT_GATHER_PARAMETER_TYPES_;
205 gatherImplementation(mem, adjustIndexParameter(std::forward<IT>(indexes)));
209 template <
typename MT,
211 typename = enable_if<Vc::Traits::has_subscript_operator<IT>::value>>
212 Vc_INTRINSIC
void gather(
const MT *mem, IT &&indexes, MaskArgument mask)
214 Vc_ASSERT_GATHER_PARAMETER_TYPES_;
215 gatherImplementation(mem, adjustIndexParameter(std::forward<IT>(indexes)), mask);
219 template <
typename S1,
typename IT>
220 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector instead.")
221 Vc_CURRENT_CLASS_NAME(const S1 *array, const EntryType S1::*member1,
222 Vc_ALIGNED_PARAMETER(IT) indexes)
224 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
225 array, indexes)[member1]
229 template <
typename S1,
typename IT>
230 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector instead.")
231 Vc_CURRENT_CLASS_NAME(const S1 *array, const EntryType S1::*member1,
232 Vc_ALIGNED_PARAMETER(IT) indexes, MaskArgument mask)
234 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
235 array, indexes)[member1]
240 template <
typename S1,
typename S2,
typename IT>
241 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector instead.")
242 Vc_CURRENT_CLASS_NAME(const S1 *array, const S2 S1::*member1,
243 const EntryType S2::*member2,
244 Vc_ALIGNED_PARAMETER(IT) indexes)
246 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
247 array, indexes)[member1][member2]
251 template <
typename S1,
typename S2,
typename IT>
252 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector instead.")
253 Vc_CURRENT_CLASS_NAME(const S1 *array, const S2 S1::*member1,
254 const EntryType S2::*member2,
255 Vc_ALIGNED_PARAMETER(IT) indexes, MaskArgument mask)
257 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
258 array, indexes)[member1][member2]
263 template <
typename S1,
typename IT1,
typename IT2>
264 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector instead.")
265 Vc_CURRENT_CLASS_NAME(const S1 *array, const EntryType *const S1::*ptrMember1,
266 Vc_ALIGNED_PARAMETER(IT1) outerIndexes,
267 Vc_ALIGNED_PARAMETER(IT2) innerIndexes)
269 gather(Common::SubscriptOperation<S1, IT1, std::ratio<1, 1>,
true>(
270 array, outerIndexes)[ptrMember1][innerIndexes]
274 template <
typename S1,
typename IT1,
typename IT2>
275 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector instead.")
276 Vc_CURRENT_CLASS_NAME(const S1 *array, const EntryType *const S1::*ptrMember1,
277 Vc_ALIGNED_PARAMETER(IT1) outerIndexes,
278 Vc_ALIGNED_PARAMETER(IT2) innerIndexes, MaskArgument mask)
280 gather(Common::SubscriptOperation<S1, IT1, std::ratio<1, 1>,
true>(
281 array, outerIndexes)[ptrMember1][innerIndexes]
286 template <
typename S1,
typename IT>
287 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
288 "instead.") void gather(const S1 *array,
289 const EntryType S1::*member1,
290 Vc_ALIGNED_PARAMETER(IT) indexes)
292 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
293 array, indexes)[member1]
297 template <
typename S1,
typename IT>
298 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
299 "instead.") void gather(const S1 *array,
300 const EntryType S1::*member1,
301 Vc_ALIGNED_PARAMETER(IT) indexes,
304 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
305 array, indexes)[member1]
310 template <
typename S1,
typename S2,
typename IT>
311 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
312 "instead.") void gather(const S1 *array, const S2 S1::*member1,
313 const EntryType S2::*member2,
314 Vc_ALIGNED_PARAMETER(IT) indexes)
316 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
317 array, indexes)[member1][member2]
321 template <
typename S1,
typename S2,
typename IT>
322 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
323 "instead.") void gather(const S1 *array, const S2 S1::*member1,
324 const EntryType S2::*member2,
325 Vc_ALIGNED_PARAMETER(IT) indexes,
328 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
329 array, indexes)[member1][member2]
334 template <
typename S1,
typename IT1,
typename IT2>
335 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
336 "instead.") void gather(const S1 *array,
337 const EntryType *const S1::*ptrMember1,
338 Vc_ALIGNED_PARAMETER(IT1) outerIndexes,
339 Vc_ALIGNED_PARAMETER(IT2) innerIndexes)
341 gather(Common::SubscriptOperation<S1, IT1, std::ratio<1, 1>,
true>(
342 array, outerIndexes)[ptrMember1][innerIndexes]
346 template <
typename S1,
typename IT1,
typename IT2>
347 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
348 "instead.") void gather(const S1 *array,
349 const EntryType *const S1::*ptrMember1,
350 Vc_ALIGNED_PARAMETER(IT1) outerIndexes,
351 Vc_ALIGNED_PARAMETER(IT2) innerIndexes,
354 gather(Common::SubscriptOperation<S1, IT1, std::ratio<1, 1>,
true>(
355 array, outerIndexes)[ptrMember1][innerIndexes]
367 template <
typename MT,
typename IT>
369 Vc_INTRINSIC
void gather(
const Common::GatherArguments<MT, IT> &args)
371 gather(args.address, adjustIndexParameter(args.indexes));
374 template <
typename MT,
typename IT>
375 Vc_INTRINSIC
void gather(
const Common::GatherArguments<MT, IT> &args, MaskArgument mask)
377 gather(args.address, adjustIndexParameter(args.indexes), mask);
381 #undef Vc_ASSERT_GATHER_PARAMETER_TYPES_