28 #ifndef VC_COMMON_VECTORTUPLE_H_
29 #define VC_COMMON_VECTORTUPLE_H_
31 #include "transpose.h"
34 namespace Vc_VERSIONED_NAMESPACE
39 template<
size_t StructSize,
typename V,
typename I,
bool Readonly = true>
struct InterleavedMemoryReadAccess;
41 template <
int Length,
typename V>
class VectorReferenceArray
43 typedef typename V::EntryType T;
44 typedef V &Vc_RESTRICT Reference;
45 std::array<V * Vc_RESTRICT, Length> r;
47 typedef make_index_sequence<Length> IndexSequence;
49 template <
typename VV, std::size_t... Indexes>
50 constexpr VectorReferenceArray<Length + 1, VV> appendOneReference(
51 VV &a, index_sequence<Indexes...>)
const
53 return {*r[Indexes]..., a};
56 template <
typename A, std::size_t... Indexes>
57 Vc_INTRINSIC
void callDeinterleave(
const A &access, index_sequence<Indexes...>)
const
59 access.deinterleave(*r[Indexes]...);
63 template <
typename... Us,
typename = enable_if<(
sizeof...(Us) == Length)>>
64 constexpr VectorReferenceArray(Us &&... args)
65 : r{{std::addressof(std::forward<Us>(args))...}}
69 template <typename VV, typename = enable_if<!std::is_const<V>::value &&
70 std::is_same<VV, V>::value>>
71 Vc_DEPRECATED(
"build the tuple with Vc::tie instead") constexpr VectorReferenceArray<
73 operator,(VV &a) const &&
75 return appendOneReference(a, IndexSequence());
78 Vc_DEPRECATED(
"build the tuple with Vc::tie instead") constexpr VectorReferenceArray<
80 operator,(const V &a) const &&
82 return appendOneReference(a, IndexSequence());
85 template <
size_t StructSize,
typename I,
bool RO>
86 Vc_ALWAYS_INLINE enable_if<(Length <= StructSize), void> operator=(
87 const InterleavedMemoryReadAccess<StructSize, V, I, RO> &access) &&
89 callDeinterleave(access, IndexSequence());
92 template <
size_t StructSize,
typename I,
bool RO>
93 enable_if<(Length > StructSize),
void>
operator=(
94 const InterleavedMemoryReadAccess<StructSize, V, I, RO> &access) && =
97 template <
typename... Inputs>
void operator=(TransposeProxy<Inputs...> &&proxy) &&
99 transpose_impl(TransposeTag<Length,
sizeof...(Inputs)>(), &r[0], proxy);
102 template <
typename T,
typename IndexVector,
typename Scale,
bool Flag>
103 void operator=(SubscriptOperation<T, IndexVector, Scale, Flag> &&sub) &&
105 const auto &args = std::move(sub).gatherArguments();
108 Common::InterleavedMemoryReadAccess<1, V, Traits::decay<decltype(args.indexes)>>
109 deinterleaver(args.address, args.indexes);
110 callDeinterleave(deinterleaver, IndexSequence());
113 Vc_ALWAYS_INLINE Reference operator[](std::size_t i) {
return *r[i]; }
118 template <
typename T,
typename Abi>
119 Vc_DEPRECATED(
"build the tuple with Vc::tie instead")
120 constexpr Common::VectorReferenceArray<2,
Vc::Vector<T, Abi>>
121 operator,(
Vc::Vector<T, Abi> &a,
Vc::Vector<T, Abi> &b)
126 template <
typename T,
typename Abi>
127 Vc_DEPRECATED(
"build the tuple with Vc::tie instead")
128 constexpr Common::VectorReferenceArray<2, const
Vc::Vector<T, Abi>>
129 operator,(const
Vc::Vector<T, Abi> &a, const
Vc::Vector<T, Abi> &b)
134 template <
typename V,
typename... Vs>
135 constexpr Common::VectorReferenceArray<
sizeof...(Vs) + 1,
136 typename std::remove_reference<V>::type>
137 tie(V &&a, Vs &&... b)
139 return {std::forward<V>(a), std::forward<Vs>(b)...};
144 #endif // VC_COMMON_VECTORTUPLE_H_