This page https://en.cppreference.com/w/cpp/experimental/simd shows only these two initialization methods of a SIMD vector:
- All elements to the same value:
native_simd<int> a = 1 - Using a lambda:
fixed_size_simd<float, 8> a([](int i) {return i;});
Is there another option? I would like this to work:
const fixed_size_simd<int, 4> a{3, 1, 4, 1};
This library doesn't provide a convenient constructor from elements at the moment, it seems.
It is worth noticing, that generator constructor #4 you mention receives a
std::integral_constant<std::size_t, i>argument, which can be used to index an array,std::tupleor a variadic function template argument at compile time.to_simdfunction below does the latter:Generated assembly is identical to hand-coded initialization using CPU-specific vector intrinsic functions.