diff --git a/c++/nda/basic_array.hpp b/c++/nda/basic_array.hpp index 3b67f21c..9b275e49 100644 --- a/c++/nda/basic_array.hpp +++ b/c++/nda/basic_array.hpp @@ -289,12 +289,15 @@ namespace nda { * @param a nda::ArrayOfRank object. */ template A> - requires(HasValueTypeConstructibleFrom) + requires(HasValueTypeConstructibleFrom) basic_array(A const &a) : lay(a.shape()), sto{lay.size(), mem::do_not_initialize} { - static_assert(std::is_constructible_v>, "Error in nda::basic_array: Incompatible value types in constructor"); + static_assert(std::is_constructible_v>, "Error in nda::basic_array: Incompatible value types in constructor"); if constexpr (std::is_trivial_v or is_complex_v) { // trivial and complex value types can use the optimized assign_from_ndarray - assign_from_ndarray(a); + if constexpr (std::is_same_v>) + assign_from_ndarray(a); + else + assign_from_ndarray(nda::map([](auto const &val) { return ValueType(val); })(a)); } else { // general value types may not be default constructible -> use placement new nda::for_each(lay.lengths(), [&](auto const &...is) { new (sto.data() + lay(is...)) ValueType{a(is...)}; });