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

View File

@@ -145,7 +145,13 @@ while(l)
template <class T>
void SparseMat<T>::copyonwrite(bool detachonly)
{
if(!count) laerror("probably an assignment to undefined sparse matrix");
if(!count)
{
if(nn||mm) laerror("nonempty sparsemat without reference count encountered");
if(_LA_warn_empty_copyonwrite) std::cout <<"Warning: copyonwrite of empty sparsemat\n";
return;
}
if(*count > 1)
{
(*count)--;