From 5fbbe35b7f9431d58ddef9cf75172fa17c85aa31 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 27 Oct 2000 13:19:29 +0000 Subject: [PATCH] Fix check for t!=0 in swap functions, and change if(t) to if(t!=0). git-svn-id: https://svn.dealii.org/trunk@3468 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/smartpointer.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/deal.II/base/include/base/smartpointer.h b/deal.II/base/include/base/smartpointer.h index 3205c707f5..7a810d08c0 100644 --- a/deal.II/base/include/base/smartpointer.h +++ b/deal.II/base/include/base/smartpointer.h @@ -182,7 +182,7 @@ template SmartPointer::SmartPointer (T *t) : t (t) { - if (t) + if (t != 0) t->subscribe(); }; @@ -192,7 +192,7 @@ template SmartPointer::SmartPointer (const SmartPointer &tt) : t (tt.t) { - if (t) + if (t != 0) t->subscribe(); }; @@ -201,7 +201,7 @@ SmartPointer::SmartPointer (const SmartPointer &tt) : template SmartPointer::~SmartPointer () { - if (t) + if (t != 0) t->unsubscribe(); }; @@ -215,10 +215,10 @@ SmartPointer & SmartPointer::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 & SmartPointer::operator = (const SmartPointer& tt) if (&tt == this) return *this; - if (t) + if (t != 0) t->unsubscribe(); t = static_cast(tt); - if (tt) + if (tt != 0) tt->subscribe(); return *this; }; @@ -284,9 +284,13 @@ template inline void SmartPointer::swap (T *&tt) { - t->unsubscribe (); + if (t != 0) + t->unsubscribe (); + std::swap (t, tt); - t->subscribe (); + + if (t != 0) + t->subscribe (); }; -- 2.39.5