]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix check for t!=0 in swap functions, and change if(t) to if(t!=0).
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 27 Oct 2000 13:19:29 +0000 (13:19 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 27 Oct 2000 13:19:29 +0000 (13:19 +0000)
git-svn-id: https://svn.dealii.org/trunk@3468 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 3205c707f515b4a9f46058b433c5e6027e3f8b6d..7a810d08c060e7a7ddfb2871367f641a63860af9 100644 (file)
@@ -182,7 +182,7 @@ template <typename T>
 SmartPointer<T>::SmartPointer (T *t) :
                t (t)
 {
-  if (t)
+  if (t != 0)
     t->subscribe();
 };
 
@@ -192,7 +192,7 @@ template <typename T>
 SmartPointer<T>::SmartPointer (const SmartPointer<T> &tt) :
                t (tt.t)
 {
-  if (t)
+  if (t != 0)
     t->subscribe();
 };
 
@@ -201,7 +201,7 @@ SmartPointer<T>::SmartPointer (const SmartPointer<T> &tt) :
 template <typename T>
 SmartPointer<T>::~SmartPointer ()
 {
-  if (t)
+  if (t != 0)
     t->unsubscribe();
 };
 
@@ -215,10 +215,10 @@ SmartPointer<T> & SmartPointer<T>::operator = (T *tt)
   if (t == tt)
     return *this;
   
-  if (t)
+  if (t != 0)
     t->unsubscribe();
   t = tt;
-  if (tt)
+  if (tt != 0)
     tt->subscribe();
   return *this;
 };
@@ -234,10 +234,10 @@ SmartPointer<T> & SmartPointer<T>::operator = (const SmartPointer<T>& tt)
   if (&tt == this)
     return *this;
   
-  if (t)
+  if (t != 0)
     t->unsubscribe();
   t = static_cast<T*>(tt);
-  if (tt)
+  if (tt != 0)
     tt->subscribe();
   return *this;
 };
@@ -284,9 +284,13 @@ template <typename T>
 inline
 void SmartPointer<T>::swap (T *&tt)
 {
-  t->unsubscribe ();
+  if (t != 0)
+    t->unsubscribe ();
+  
   std::swap (t, tt);
-  t->subscribe ();
+
+  if (t != 0)
+    t->subscribe ();
 };
 
 

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.