commit 8015037e306c16313de730484835b72b048cc928
parent e7cc84b8d8db5aef851704482931682ea42261e5
Author: [email protected] <[email protected]>
Date: Thu, 4 Aug 2022 13:06:36 +0100
Construct vec from lambda
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/include/kfr/simd/vec.hpp b/include/kfr/simd/vec.hpp
@@ -270,6 +270,16 @@ struct alignas(internal::vec_alignment<T, N_>) vec
{
}
+ // from lambda
+ template <typename Fn, KFR_ENABLE_IF(is_callable<Fn, size_t>)>
+ KFR_MEM_INTRINSIC vec(Fn&& fn) CMT_NOEXCEPT
+ {
+ for (size_t i = 0; i < N; ++i)
+ {
+ set(i, fn(i));
+ }
+ }
+
template <typename U, KFR_ENABLE_IF(is_convertible<U, value_type> &&
!(compound_type_traits<T>::is_scalar && !is_bit<U>))>
KFR_MEM_INTRINSIC vec(const vec<U, N>& x) CMT_NOEXCEPT