29 #ifndef VC_COMMON_MAKECONTAINER_H_
30 #define VC_COMMON_MAKECONTAINER_H_
32 #include <Vc/vector.h>
33 #include <initializer_list>
36 namespace Vc_VERSIONED_NAMESPACE
41 template<
typename Container,
typename T>
struct make_container_helper
43 static constexpr Container help(std::initializer_list<T> list) {
return { list }; }
46 template<
typename _T,
typename Alloc,
template<
class,
class>
class Container>
49 typedef ::Vc::Vector<_T> V;
50 typedef typename V::EntryType T;
51 typedef Container<V, Alloc> C;
52 static inline C help(std::initializer_list<T> list) {
53 const std::size_t size = (list.size() + (V::Size - 1)) / V::Size;
55 auto containerIt = v.begin();
56 auto init = std::begin(list);
57 const auto initEnd = std::end(list);
58 for (std::size_t i = 0; i < size - 1; ++i) {
64 while (init != initEnd) {
65 (*containerIt)[j++] = *init++;
71 template<
typename _T, std::
size_t N,
template<
class, std::
size_t>
class Container>
74 typedef ::Vc::Vector<_T> V;
75 typedef typename V::EntryType T;
76 static constexpr std::size_t size = (N + (V::Size - 1)) / V::Size;
77 typedef Container<V, size> C;
78 static inline C help(std::initializer_list<T> list) {
79 Vc_ASSERT(N == list.size())
80 Vc_ASSERT(size == (list.size() + (V::Size - 1)) / V::Size)
82 auto containerIt = v.begin();
83 auto init = std::begin(list);
84 const auto initEnd = std::end(list);
85 for (std::size_t i = 0; i < size - 1; ++i) {
91 while (init != initEnd) {
92 (*containerIt)[j++] = *init++;
121 template<
typename Container,
typename T>
122 constexpr
auto makeContainer(std::initializer_list<T> list) -> decltype(make_container_helper<Container, T>::help(list))
124 return make_container_helper<Container, T>::help(list);
127 template<
typename Container,
typename T>
128 constexpr
auto make_container(std::initializer_list<T> list) -> decltype(makeContainer<Container, T>(list))
130 return makeContainer<Container, T>(list);
135 #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.
The main vector class for expressing data parallelism.
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.