allow trivial copyonwrite() on empty vec/mat/...

This commit is contained in:
2021-11-04 14:21:13 +01:00
parent 9c6ab037cf
commit 6715260da7
7 changed files with 32 additions and 6 deletions

7
vec.h
View File

@@ -1011,7 +1011,12 @@ NRVec<T>::~NRVec() {
******************************************************************************/
template <typename T>
void NRVec<T>::copyonwrite(bool detachonly) {
if(!count) laerror("copyonwrite of an undefined vector");
if(!count)
{
if(nn) laerror("nonempty vector without reference count encountered");
if(_LA_warn_empty_copyonwrite) std::cout <<"Warning: copyonwrite of empty vector\n";
return;
}
if(*count > 1) {
(*count)--;
count = new int;