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
smat.h
View File

@@ -957,7 +957,12 @@ NRSMat<T> & NRSMat<T>::operator=(const NRSMat<T> & rhs) {
******************************************************************************/
template <typename T>
void NRSMat<T>::copyonwrite(bool detachonly) {
if(!count) laerror("calling NRSMat<T>::copyonwrite() for undefined NRSMat<T> object");
if(!count)
{
if(nn) laerror("nonempty smat without reference count encountered");
if(_LA_warn_empty_copyonwrite) std::cout <<"Warning: copyonwrite of empty smat\n";
return;
}
if(*count > 1){
(*count)--;
count = new int;