28 #ifndef VC_COMMON_MAKECONTAINER_H_ 29 #define VC_COMMON_MAKECONTAINER_H_ 31 #include "../vector.h" 32 #include <initializer_list> 34 namespace Vc_VERSIONED_NAMESPACE
39 template<
typename Container,
typename T>
struct make_container_helper
41 static constexpr Container help(std::initializer_list<T> list) {
return { list }; }
44 template <
typename T_,
typename Abi,
typename Alloc,
45 template <
class,
class>
class Container>
46 struct make_container_helper<Container<Vector<T_, Abi>, Alloc>,
47 typename Vector<T_, Abi>::EntryType> {
48 typedef Vector<T_, Abi> V;
49 typedef typename V::EntryType T;
50 typedef Container<V, Alloc> C;
51 static inline C help(std::initializer_list<T> list) {
52 const std::size_t size = (list.size() + (V::Size - 1)) / V::Size;
54 auto containerIt = v.begin();
55 auto init = std::begin(list);
56 const auto initEnd = std::end(list);
57 for (std::size_t i = 0; i < size - 1; ++i) {
63 while (init != initEnd) {
64 (*containerIt)[j++] = *init++;
70 template <
typename T_,
typename Abi, std::size_t N,
71 template <
class, std::
size_t>
class Container>
72 struct make_container_helper<Container<Vector<T_, Abi>, N>,
73 typename Vector<T_, Abi>::EntryType> {
74 typedef Vector<T_, Abi> V;
75 typedef typename V::EntryType T;
76 static constexpr std::size_t size = (N + (V::Size - 1)) / V::Size;
79 #if defined Vc_CLANG && Vc_CLANG < 0x30700 // TODO: when did Vc_APPLECLANG fix it? 83 (size == 1 && std::is_same<Abi, VectorAbi::Avx>::value) ? 2 :
86 static inline C help(std::initializer_list<T> list) {
87 Vc_ASSERT(N == list.size())
88 Vc_ASSERT(size == (list.size() + (V::Size - 1)) / V::Size)
90 auto containerIt = v.begin();
91 auto init = std::begin(list);
92 const auto initEnd = std::end(list);
93 for (std::size_t i = 0; i < size - 1; ++i) {
99 while (init != initEnd) {
100 (*containerIt)[j++] = *init++;
136 template<
typename Container,
typename T>
137 constexpr
auto makeContainer(std::initializer_list<T> list) -> decltype(make_container_helper<Container, T>::help(list))
139 return make_container_helper<Container, T>::help(list);
142 template<
typename Container,
typename T>
143 constexpr
auto make_container(std::initializer_list<T> list) -> decltype(makeContainer<Container, T>(list))
145 return makeContainer<Container, T>(list);
150 #endif // VC_COMMON_MAKECONTAINER_H_ constexpr auto makeContainer(std::initializer_list< T > list) -> decltype(make_container_helper< Container, T >::help(list))
Construct a container of Vc vectors from a std::initializer_list of scalar entries.
constexpr bool all_of(const Mask &m)
Returns whether all entries in the mask m are true.
constexpr VectorSpecialInitializerZero Zero
The special object Vc::Zero can be used to construct Vector and Mask objects initialized to zero/fals...
constexpr UnalignedTag Unaligned
Use this object for a flags parameter to request unaligned loads and stores.