From 2193763cc111ef391c1d5c19c3ceb697c9716283 Mon Sep 17 00:00:00 2001 From: hartmann Date: Thu, 26 Sep 2002 15:33:07 +0000 Subject: [PATCH] Use of SmartPointer: Table should only be deleted when there does not exist an Accessor of it any more. git-svn-id: https://svn.dealii.org/trunk@6528 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/table.h | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/deal.II/base/include/base/table.h b/deal.II/base/include/base/table.h index b6bd7c7259..268c11f568 100644 --- a/deal.II/base/include/base/table.h +++ b/deal.II/base/include/base/table.h @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -398,7 +399,7 @@ namespace TableBaseAccessors * no reason not to make these * elements constant. */ - const TableType &table; + SmartPointer table; const pointer data; }; @@ -502,7 +503,7 @@ namespace TableBaseAccessors * no reason not to make these * elements constant. */ - const TableType &table; + SmartPointer table; const pointer data; }; }; @@ -1622,7 +1623,7 @@ namespace TableBaseAccessors Accessor::Accessor (const TableType &table, const pointer data) : - table (table), + table (&table), data (data) {}; @@ -1633,24 +1634,24 @@ namespace TableBaseAccessors Accessor Accessor::operator [] (const unsigned int i) const { - Assert (i < table.size()[N-P], - ExcIndexRange (i, 0, table.size()[N-P])); + Assert (i < table->size()[N-P], + ExcIndexRange (i, 0, table->size()[N-P])); // access i-th // subobject. optimize on the // case i==0 if (i==0) - return Accessor (table, data); + return Accessor (*table, data); else { // note: P>1, otherwise the // specialization would have // been taken! - unsigned int subobject_size = table.size()[N-1]; + unsigned int subobject_size = table->size()[N-1]; for (int p=P-1; p>1; --p) - subobject_size *= table.size()[N-p]; + subobject_size *= table->size()[N-p]; const pointer new_data = data + i*subobject_size; - return Accessor (table, new_data); + return Accessor (*table, new_data); }; }; @@ -1661,7 +1662,7 @@ namespace TableBaseAccessors Accessor::Accessor (const TableType &table, const pointer data) : - table (table), + table (&table), data (data) {}; @@ -1672,8 +1673,8 @@ namespace TableBaseAccessors typename Accessor::reference Accessor::operator [] (const unsigned int i) const { - Assert (i < table.size()[N-1], - ExcIndexRange (i, 0, table.size()[N-1])); + Assert (i < table->size()[N-1], + ExcIndexRange (i, 0, table->size()[N-1])); return data[i]; }; @@ -1684,7 +1685,7 @@ namespace TableBaseAccessors unsigned int Accessor::size () const { - return table.size()[N-1]; + return table->size()[N-1]; }; @@ -1704,7 +1705,7 @@ namespace TableBaseAccessors typename Accessor::iterator Accessor::end () const { - return data+table.size()[N-1]; + return data+table->size()[N-1]; }; }; -- 2.39.5