29 #ifndef VC_COMMON_VECTORTUPLE_H_
30 #define VC_COMMON_VECTORTUPLE_H_
32 #include "transpose.h"
35 namespace Vc_VERSIONED_NAMESPACE
40 template<
size_t StructSize,
typename V,
typename I,
bool Readonly = true>
struct InterleavedMemoryReadAccess;
42 template <
int Length,
typename V>
class VectorReferenceArray
44 typedef typename V::EntryType T;
45 typedef V &Vc_RESTRICT Reference;
46 std::array<V * Vc_RESTRICT, Length> r;
48 typedef make_index_sequence<Length> IndexSequence;
50 template <
typename VV, std::size_t... Indexes>
51 constexpr VectorReferenceArray<Length + 1, VV> appendOneReference(
52 VV &a, index_sequence<Indexes...>)
const
54 return {*r[Indexes]..., a};
57 template <
typename A, std::size_t... Indexes>
58 Vc_INTRINSIC
void callDeinterleave(
const A &access, index_sequence<Indexes...>)
const
60 access.deinterleave(*r[Indexes]...);
64 template <
typename... Us,
typename = enable_if<(
sizeof...(Us) == Length)>>
65 constexpr VectorReferenceArray(Us &&... args)
66 : r{{std::addressof(std::forward<Us>(args))...}}
70 template <typename VV, typename = enable_if<!std::is_const<V>::value &&
71 std::is_same<VV, V>::value>>
72 Vc_DEPRECATED(
"build the tuple with Vc::tie instead")
73 constexpr VectorReferenceArray<Length + 1, V> operator, (VV & a)
const
75 return appendOneReference(a, IndexSequence());
78 Vc_DEPRECATED(
"build the tuple with Vc::tie instead")
79 constexpr VectorReferenceArray<Length + 1, const V> operator, (const V &a)
const
81 return appendOneReference(a, IndexSequence());
84 template <
size_t StructSize,
typename I,
bool RO>
85 Vc_ALWAYS_INLINE enable_if<(Length <= StructSize), void> operator=(
86 const InterleavedMemoryReadAccess<StructSize, V, I, RO> &access)
88 callDeinterleave(access, IndexSequence());
91 template <
size_t StructSize,
typename I,
bool RO>
92 enable_if<(Length > StructSize),
void>
operator=(
93 const InterleavedMemoryReadAccess<StructSize, V, I, RO> &access) =
96 template <
typename... Inputs>
void operator=(TransposeProxy<Inputs...> &&proxy)
98 transpose_impl<Length>(&r[0], proxy);
101 template <
typename T,
typename IndexVector,
typename Scale,
bool Flag>
102 void operator=(
const SubscriptOperation<T, IndexVector, Scale, Flag> &sub)
104 const auto &args = sub.gatherArguments();
107 Common::InterleavedMemoryReadAccess<1, V, Traits::decay<decltype(args.indexes)>>
108 deinterleaver(args.address, args.indexes);
109 callDeinterleave(deinterleaver, IndexSequence());
112 Vc_ALWAYS_INLINE Reference operator[](std::size_t i) {
return *r[i]; }
117 template <
typename T,
typename Abi>
118 Vc_DEPRECATED(
"build the tuple with Vc::tie instead")
119 constexpr Common::VectorReferenceArray<2,
Vc::Vector<T, Abi>>
120 operator,(
Vc::Vector<T, Abi> &a,
Vc::Vector<T, Abi> &b)
125 template <
typename T,
typename Abi>
126 Vc_DEPRECATED(
"build the tuple with Vc::tie instead")
127 constexpr Common::VectorReferenceArray<2, const
Vc::Vector<T, Abi>>
128 operator,(const
Vc::Vector<T, Abi> &a, const
Vc::Vector<T, Abi> &b)
133 template <
typename V,
typename... Vs>
134 constexpr Common::VectorReferenceArray<
sizeof...(Vs) + 1,
135 typename std::remove_reference<V>::type>
136 tie(V &&a, Vs &&... b)
138 return {std::forward<V>(a), std::forward<Vs>(b)...};
143 #endif // VC_COMMON_VECTORTUPLE_H_
Vector Classes Namespace.