xsimd
xsimd copied to clipboard
Add constructors from intializer lists and helpers
Batch constructor taking an initializer list should be available. Helpers allowing to build batches from initializer lists without knowing their real type should be implemented too.
For the record, something similar (using boost.simd syntax) works just fine for my use case
template<class P, size_t... Is>
P iota(std::index_sequence<Is...>) {
return {static_cast<typename P::value_type>(Is)...};
}
template<class P>
P iota() {
return iota<P>(std::make_index_sequence<P::static_size>());
}
called as
iota<boost::simd::pack<T>>()
Since you know the length at compile time, shouldn't you take an std::array<T, N> instead of an initializer_list? Seems to me that it would avoid brace initialization confusion with the constructor taking N scalars...
At some point we've been supporting initializer lists, but they turned out to be confusing for users. This got removed by 3ce1809f417703bc804de4fc1b3310c678b823d2 as an answer to #775.
Current supported constructor has the following signature:
template <class T, class A>
template <class... Ts>
inline batch<T, A>::batch(T val0, T val1, Ts... vals) noexcept
And it performs compile-time checking on the number of elements to make sure they match batch size.