From: guido Date: Fri, 5 Feb 1999 19:48:45 +0000 (+0000) Subject: Assignment of two SmartPointers X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=676633f094156622b507fcbbd89c8d774a10f911;p=dealii-svn.git Assignment of two SmartPointers git-svn-id: https://svn.dealii.org/trunk@761 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/smartpointer.h b/deal.II/base/include/base/smartpointer.h index 0145930390..57bfd85444 100644 --- a/deal.II/base/include/base/smartpointer.h +++ b/deal.II/base/include/base/smartpointer.h @@ -65,11 +65,18 @@ class SmartPointer ~SmartPointer(); /** - * Assignment operator. Change of + * Assignment operator for + * normal pointers. Change of * subscription is necessary. */ SmartPointer & operator= (T *tt); - + + /** + *Assignment operator for + * #SmartPointer#. Change of + * subscription is necessary. + */ + SmartPointer & operator= (const SmartPointer& tt); /** * Conversion to normal pointer. @@ -91,7 +98,7 @@ class SmartPointer * Pointer to the object we want * to subscribt to. */ - const T* t; + T * t; }; @@ -137,6 +144,16 @@ SmartPointer & SmartPointer::operator = (T *tt) { }; +template +SmartPointer & SmartPointer::operator = (const SmartPointer& tt) { + if (t) + t->unsubscribe(); + t = (T*) tt; + if (tt) + tt->subscribe(); + return *this; +}; + template inline