]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Assignment of two SmartPointers
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 5 Feb 1999 19:48:45 +0000 (19:48 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 5 Feb 1999 19:48:45 +0000 (19:48 +0000)
git-svn-id: https://svn.dealii.org/trunk@761 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/smartpointer.h

index 01459303906abe61a1bca4dfe448b290b2edde20..57bfd85444f50d407c0b0fb1aecf361913f2f6ca 100644 (file)
@@ -65,11 +65,18 @@ class SmartPointer
     ~SmartPointer();
     
                                     /**
-                                     * Assignment operator. Change of
+                                     * Assignment operator for
+                                     * normal pointers. Change of
                                      * subscription is necessary.
                                      */
     SmartPointer<T> & operator= (T *tt);
-  
+
+                                    /**
+                                     *Assignment operator for
+                                     * #SmartPointer#. Change of
+                                     * subscription is necessary.
+                                     */
+    SmartPointer<T> & operator= (const SmartPointer<T>& tt);
 
                                     /**
                                      * Conversion to normal pointer.
@@ -91,7 +98,7 @@ class SmartPointer
                                      * Pointer to the object we want
                                      * to subscribt to.
                                      */
-    const T* t;
+  * t;
 };
 
 
@@ -137,6 +144,16 @@ SmartPointer<T> & SmartPointer<T>::operator = (T *tt) {
 };
 
 
+template <typename T>
+SmartPointer<T> & SmartPointer<T>::operator = (const SmartPointer<T>& tt) {
+  if (t)
+    t->unsubscribe();
+  t = (T*) tt;
+  if (tt)
+    tt->subscribe();
+  return *this;
+};
+
 
 template <typename T>
 inline

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.