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")
72 constexpr VectorReferenceArray<Length + 1, V> operator, (VV & a)
const
74 return appendOneReference(a, IndexSequence());
77 Vc_DEPRECATED(
"build the tuple with Vc::tie instead")
78 constexpr VectorReferenceArray<Length + 1, const V> operator, (const V &a)
const
80 return appendOneReference(a, IndexSequence());
83 template <
size_t StructSize,
typename I,
bool RO>
84 Vc_ALWAYS_INLINE enable_if<(Length <= StructSize), void> operator=(
85 const InterleavedMemoryReadAccess<StructSize, V, I, RO> &access)
87 callDeinterleave(access, IndexSequence());
90 template <
size_t StructSize,
typename I,
bool RO>
91 enable_if<(Length > StructSize),
void>
operator=(
92 const InterleavedMemoryReadAccess<StructSize, V, I, RO> &access) =
95 template <
typename... Inputs>
void operator=(TransposeProxy<Inputs...> &&proxy)
97 transpose_impl(TransposeTag<Length,
sizeof...(Inputs)>(), &r[0], proxy);
100 template <
typename T,
typename IndexVector,
typename Scale,
bool Flag>
101 void operator=(
const SubscriptOperation<T, IndexVector, Scale, Flag> &sub)
103 const auto &args = sub.gatherArguments();
106 Common::InterleavedMemoryReadAccess<1, V, Traits::decay<decltype(args.indexes)>>
107 deinterleaver(args.address, args.indexes);
108 callDeinterleave(deinterleaver, IndexSequence());
111 Vc_ALWAYS_INLINE Reference operator[](std::size_t i) {
return *r[i]; }
116 template <
typename T,
typename Abi>
117 Vc_DEPRECATED(
"build the tuple with Vc::tie instead")
118 constexpr Common::VectorReferenceArray<2,
Vc::Vector<T, Abi>>
119 operator,(
Vc::Vector<T, Abi> &a,
Vc::Vector<T, Abi> &b)
124 template <
typename T,
typename Abi>
125 Vc_DEPRECATED(
"build the tuple with Vc::tie instead")
126 constexpr Common::VectorReferenceArray<2, const
Vc::Vector<T, Abi>>
127 operator,(const
Vc::Vector<T, Abi> &a, const
Vc::Vector<T, Abi> &b)
132 template <
typename V,
typename... Vs>
133 constexpr Common::VectorReferenceArray<
sizeof...(Vs) + 1,
134 typename std::remove_reference<V>::type>
135 tie(V &&a, Vs &&... b)
137 return {std::forward<V>(a), std::forward<Vs>(b)...};
142 #endif // VC_COMMON_VECTORTUPLE_H_
Vector Classes Namespace.