From 676633f094156622b507fcbbd89c8d774a10f911 Mon Sep 17 00:00:00 2001 From: guido Date: Fri, 5 Feb 1999 19:48:45 +0000 Subject: [PATCH] Assignment of two SmartPointers git-svn-id: https://svn.dealii.org/trunk@761 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/smartpointer.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) 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 -- 2.39.5