Fix util::ndarray::copy() in case of an empty array
This commit is contained in:
parent
c3f48fdbc0
commit
d1a3bf15d4
1 changed files with 3 additions and 0 deletions
|
|
@ -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)};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue