Fix util::ndarray::copy() in case of an empty array

This commit is contained in:
Nikita Lisitsa 2026-02-20 20:19:32 +03:00
parent c3f48fdbc0
commit d1a3bf15d4

View file

@ -379,6 +379,9 @@ namespace psemek::util
template <typename T, std::size_t N>
ndarray<T, N> ndarray<T, N>::copy() const
{
if (empty())
return {};
std::unique_ptr<T[]> data(new T[size()]);
std::copy(begin(), end(), data.get());
return ndarray{dims_, std::move(data)};