check copy_assignable also in copy-constructor

This commit is contained in:
Joachim Schöberl 2020-09-09 07:03:12 +02:00
parent 98697959dd
commit 65761e7768

View File

@ -712,10 +712,15 @@ namespace ngcore
NETGEN_INLINE explicit Array (const Array & a2)
: FlatArray<T,IndexType> (a2.Size(), a2.Size() ? new T[a2.Size()] : nullptr)
{
allocsize = size;
mem_to_delete = data;
for (size_t i = 0; i < size; i++)
data[i] = a2.data[i];
if constexpr (std::is_copy_assignable<T>::value)
{
allocsize = size;
mem_to_delete = data;
for (size_t i = 0; i < size; i++)
data[i] = a2.data[i];
}
else
throw Exception(std::string("cannot copy-construct Array of type ") + typeid(T).name());
}