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);
234 template <
typename S1,
typename IT>
235 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector instead.")
236 Vc_CURRENT_CLASS_NAME(const S1 *array, const EntryType S1::*member1,
237 Vc_ALIGNED_PARAMETER(IT) indexes)
239 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
240 array, indexes)[member1]
257 template <
typename S1,
typename IT>
258 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector instead.")
259 Vc_CURRENT_CLASS_NAME(const S1 *array, const EntryType S1::*member1,
260 Vc_ALIGNED_PARAMETER(IT) indexes, MaskArgument mask)
262 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
263 array, indexes)[member1]
282 template <
typename S1,
typename S2,
typename IT>
283 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector instead.")
284 Vc_CURRENT_CLASS_NAME(const S1 *array, const S2 S1::*member1,
285 const EntryType S2::*member2,
286 Vc_ALIGNED_PARAMETER(IT) indexes)
288 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
289 array, indexes)[member1][member2]
308 template <
typename S1,
typename S2,
typename IT>
309 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector instead.")
310 Vc_CURRENT_CLASS_NAME(const S1 *array, const S2 S1::*member1,
311 const EntryType S2::*member2,
312 Vc_ALIGNED_PARAMETER(IT) indexes, MaskArgument mask)
314 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
315 array, indexes)[member1][member2]
331 template <
typename S1,
typename IT1,
typename IT2>
332 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector instead.")
333 Vc_CURRENT_CLASS_NAME(const S1 *array, const EntryType *const S1::*ptrMember1,
334 Vc_ALIGNED_PARAMETER(IT1) outerIndexes,
335 Vc_ALIGNED_PARAMETER(IT2) innerIndexes)
337 gather(Common::SubscriptOperation<S1, IT1, std::ratio<1, 1>,
true>(
338 array, outerIndexes)[ptrMember1][innerIndexes]
354 template <
typename S1,
typename IT1,
typename IT2>
355 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector instead.")
356 Vc_CURRENT_CLASS_NAME(const S1 *array, const EntryType *const S1::*ptrMember1,
357 Vc_ALIGNED_PARAMETER(IT1) outerIndexes,
358 Vc_ALIGNED_PARAMETER(IT2) innerIndexes, MaskArgument mask)
360 gather(Common::SubscriptOperation<S1, IT1, std::ratio<1, 1>,
true>(
361 array, outerIndexes)[ptrMember1][innerIndexes]
378 template <
typename S1,
typename IT>
379 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
380 "instead.") void gather(const S1 *array,
381 const EntryType S1::*member1,
382 Vc_ALIGNED_PARAMETER(IT) indexes)
384 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
385 array, indexes)[member1]
402 template <
typename S1,
typename IT>
403 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
404 "instead.") void gather(const S1 *array,
405 const EntryType S1::*member1,
406 Vc_ALIGNED_PARAMETER(IT) indexes,
409 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
410 array, indexes)[member1]
429 template <
typename S1,
typename S2,
typename IT>
430 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
431 "instead.") void gather(const S1 *array, const S2 S1::*member1,
432 const EntryType S2::*member2,
433 Vc_ALIGNED_PARAMETER(IT) indexes)
435 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
436 array, indexes)[member1][member2]
455 template <
typename S1,
typename S2,
typename IT>
456 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
457 "instead.") void gather(const S1 *array, const S2 S1::*member1,
458 const EntryType S2::*member2,
459 Vc_ALIGNED_PARAMETER(IT) indexes,
462 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
463 array, indexes)[member1][member2]
479 template <
typename S1,
typename IT1,
typename IT2>
480 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
481 "instead.") void gather(const S1 *array,
482 const EntryType *const S1::*ptrMember1,
483 Vc_ALIGNED_PARAMETER(IT1) outerIndexes,
484 Vc_ALIGNED_PARAMETER(IT2) innerIndexes)
486 gather(Common::SubscriptOperation<S1, IT1, std::ratio<1, 1>,
true>(
487 array, outerIndexes)[ptrMember1][innerIndexes]
503 template <
typename S1,
typename IT1,
typename IT2>
504 inline Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
505 "instead.") void gather(const S1 *array,
506 const EntryType *const S1::*ptrMember1,
507 Vc_ALIGNED_PARAMETER(IT1) outerIndexes,
508 Vc_ALIGNED_PARAMETER(IT2) innerIndexes,
511 gather(Common::SubscriptOperation<S1, IT1, std::ratio<1, 1>,
true>(
512 array, outerIndexes)[ptrMember1][innerIndexes]
524 template <
typename MT,
typename IT>
526 Vc_INTRINSIC
void gather(
const Common::GatherArguments<MT, IT> &args)
528 gather(args.address, adjustIndexParameter(args.indexes));
531 template <
typename MT,
typename IT>
532 Vc_INTRINSIC
void gather(
const Common::GatherArguments<MT, IT> &args, MaskArgument mask)
534 gather(args.address, adjustIndexParameter(args.indexes), mask);
538 #undef Vc_ASSERT_GATHER_PARAMETER_TYPES_