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.")
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,
const IT &indexes)
185 Vc_ASSERT_GATHER_PARAMETER_TYPES_;
186 gatherImplementation(mem, adjustIndexParameter(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,
const IT &indexes,
195 Vc_ASSERT_GATHER_PARAMETER_TYPES_;
196 gatherImplementation(mem, adjustIndexParameter(indexes), mask);
200 template <
typename MT,
typename IT,
201 typename = enable_if<Vc::Traits::has_subscript_operator<IT>::value>>
202 Vc_INTRINSIC
void gather(
const MT *mem,
const IT &indexes)
204 Vc_ASSERT_GATHER_PARAMETER_TYPES_;
205 gatherImplementation(mem, adjustIndexParameter(indexes));
209 template <
typename MT,
typename IT,
210 typename = enable_if<Vc::Traits::has_subscript_operator<IT>::value>>
211 Vc_INTRINSIC
void gather(
const MT *mem,
const IT &indexes, MaskArgument mask)
213 Vc_ASSERT_GATHER_PARAMETER_TYPES_;
214 gatherImplementation(mem, adjustIndexParameter(indexes), mask);
233 template <
typename S1,
typename IT>
234 Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
235 "instead.") inline Vc_CURRENT_CLASS_NAME(const S1 *array,
236 const EntryType S1::*member1,
239 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
240 array, indexes)[member1]
257 template <
typename S1,
typename IT>
258 Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
259 "instead.") inline Vc_CURRENT_CLASS_NAME(const S1 *array,
260 const EntryType S1::*member1,
261 IT indexes, MaskArgument mask)
263 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
264 array, indexes)[member1]
283 template <
typename S1,
typename S2,
typename IT>
284 Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
285 "instead.") inline Vc_CURRENT_CLASS_NAME(const S1 *array,
286 const S2 S1::*member1,
287 const EntryType S2::*member2,
290 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
291 array, indexes)[member1][member2]
310 template <
typename S1,
typename S2,
typename IT>
311 Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
312 "instead.") inline Vc_CURRENT_CLASS_NAME(const S1 *array,
313 const S2 S1::*member1,
314 const EntryType S2::*member2,
315 IT indexes, MaskArgument mask)
317 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
318 array, indexes)[member1][member2]
334 template <
typename S1,
typename IT1,
typename IT2>
336 "use the subscript operator to Vc::array or Vc::vector "
337 "instead.") inline Vc_CURRENT_CLASS_NAME(const S1 *array,
338 const EntryType *const S1::*ptrMember1,
339 IT1 outerIndexes, IT2 innerIndexes)
341 gather(Common::SubscriptOperation<S1, IT1, std::ratio<1, 1>,
true>(
342 array, outerIndexes)[ptrMember1][innerIndexes]
358 template <
typename S1,
typename IT1,
typename IT2>
360 "use the subscript operator to Vc::array or Vc::vector "
361 "instead.") inline Vc_CURRENT_CLASS_NAME(const S1 *array,
362 const EntryType *const S1::*ptrMember1,
363 IT1 outerIndexes, IT2 innerIndexes,
366 gather(Common::SubscriptOperation<S1, IT1, std::ratio<1, 1>,
true>(
367 array, outerIndexes)[ptrMember1][innerIndexes]
384 template <
typename S1,
typename IT>
385 Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
386 "instead.") inline
void gather(const S1 *array,
387 const EntryType S1::*member1, IT indexes)
389 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
390 array, indexes)[member1]
407 template <
typename S1,
typename IT>
408 Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
409 "instead.") inline
void gather(const S1 *array,
410 const EntryType S1::*member1,
414 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
415 array, indexes)[member1]
434 template <
typename S1,
typename S2,
typename IT>
435 Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
436 "instead.") inline
void gather(const S1 *array, const S2 S1::*member1,
437 const EntryType S2::*member2, IT indexes)
439 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
440 array, indexes)[member1][member2]
459 template <
typename S1,
typename S2,
typename IT>
460 Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
461 "instead.") inline
void gather(const S1 *array, const S2 S1::*member1,
462 const EntryType S2::*member2, IT indexes,
465 gather(Common::SubscriptOperation<S1, IT, std::ratio<1, 1>,
true>(
466 array, indexes)[member1][member2]
482 template <
typename S1,
typename IT1,
typename IT2>
483 Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
484 "instead.") inline
void gather(const S1 *array,
485 const EntryType *const S1::*ptrMember1,
486 IT1 outerIndexes, IT2 innerIndexes)
488 gather(Common::SubscriptOperation<S1, IT1, std::ratio<1, 1>,
true>(
489 array, outerIndexes)[ptrMember1][innerIndexes]
505 template <
typename S1,
typename IT1,
typename IT2>
506 Vc_DEPRECATED(
"use the subscript operator to Vc::array or Vc::vector "
507 "instead.") inline
void gather(const S1 *array,
508 const EntryType *const S1::*ptrMember1,
509 IT1 outerIndexes, IT2 innerIndexes,
512 gather(Common::SubscriptOperation<S1, IT1, std::ratio<1, 1>,
true>(
513 array, outerIndexes)[ptrMember1][innerIndexes]
525 template <
typename MT,
typename IT>
527 Vc_INTRINSIC
void gather(
const Common::GatherArguments<MT, IT> &args)
529 gather(args.address, adjustIndexParameter(args.indexes));
532 template <
typename MT,
typename IT>
533 Vc_INTRINSIC
void gather(
const Common::GatherArguments<MT, IT> &args, MaskArgument mask)
535 gather(args.address, adjustIndexParameter(args.indexes), mask);
539 #undef Vc_ASSERT_GATHER_PARAMETER_TYPES_