From: wolf Date: Tue, 8 Jun 1999 16:02:28 +0000 (+0000) Subject: Fix a problem with the newly introduced copy operator. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a09821e269981fcfc2a06cbbe9c6b0e14eea3181;p=dealii-svn.git Fix a problem with the newly introduced copy operator. git-svn-id: https://svn.dealii.org/trunk@1386 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/sparse_matrix.h b/deal.II/lac/include/lac/sparse_matrix.h index 7304fae8af..f2fbec3589 100644 --- a/deal.II/lac/include/lac/sparse_matrix.h +++ b/deal.II/lac/include/lac/sparse_matrix.h @@ -88,6 +88,14 @@ class SparseMatrixStruct : public Subscriptor SparseMatrixStruct (const unsigned int n, const unsigned int max_per_row); + /** + * Copy operator. For this the same holds + * as for the copy constructor: it is + * declared, defined and fine to be called, + * but the latter only for empty objects. + */ + SparseMatrixStruct & operator = (const SparseMatrixStruct &); + /** * Make a copy with extra off-diagonals. * @@ -535,14 +543,6 @@ class SparseMatrixStruct : public Subscriptor */ bool compressed; - /** - * Copy operator. Declare but don't - * define it and make it private above - * that to avoid that anyone tries to - * use this operator. - */ - SparseMatrixStruct & operator = (const SparseMatrixStruct &); - template friend class SparseMatrix; }; diff --git a/deal.II/lac/source/sparse_matrix.cc b/deal.II/lac/source/sparse_matrix.cc index d1ae0644c5..63650cbe30 100644 --- a/deal.II/lac/source/sparse_matrix.cc +++ b/deal.II/lac/source/sparse_matrix.cc @@ -164,6 +164,26 @@ SparseMatrixStruct::~SparseMatrixStruct () +SparseMatrixStruct & +SparseMatrixStruct::opertor = (const SparseMatrixStruct &s) +{ + Assert (s.rowstart == 0, ExcInvalidConstructorCall()); + Assert (s.colnums == 0, ExcInvalidConstructorCall()); + Assert (s.rows == 0, ExcInvalidConstructorCall()); + Assert (s.cols == 0, ExcInvalidConstructorCall()); + + // no need to free existing arrays, since we + // should never get here. + max_dim = 0; + max_vec_len = 0; + rowstart = 0; + colnums = 0; + + reinit (0,0,0); +}; + + + void SparseMatrixStruct::reinit (const unsigned int m,