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

8
mat.h
View File

@@ -1089,7 +1089,13 @@ NRMat<T> & NRMat<T>::operator|=(const NRMat<T> &rhs) {
******************************************************************************/
template <typename T>
void NRMat<T>::copyonwrite(bool detachonly) {
if(!count) laerror("attempt to call copyonwrite() for a matrix with count == 0");
if(!count)
{
if(nn||mm) laerror("nonempty matrix without reference count encountered");
if(_LA_warn_empty_copyonwrite) std::cout <<"Warning: copyonwrite of empty matrix\n";
return;
}
if(*count > 1){
(*count)--;
count = new int;