Array copy only if type is assignable

This commit is contained in:
Joachim Schöberl 2020-09-08 23:00:03 +02:00
parent 5c2089ed96
commit b2b8a15611

View File

@ -940,11 +940,16 @@ namespace ngcore
/// array copy
NETGEN_INLINE Array & operator= (const Array & a2)
{
SetSize0 ();
SetSize (a2.Size());
for (size_t i = 0; i < size; i++)
data[i] = a2.data[i];
return *this;
if constexpr (std::is_assignable<T,T>::value)
{
SetSize0 ();
SetSize (a2.Size());
for (size_t i = 0; i < size; i++)
data[i] = a2.data[i];
return *this;
}
else
throw Exception(std::string("cannot copy Array of type ") + typeid(T).name());
}
/// steal array