From 10dc6ed60fbf2ef68d7fd37f1eb1f0a54760daaf Mon Sep 17 00:00:00 2001 From: kanschat Date: Thu, 11 Nov 2010 21:07:28 +0000 Subject: [PATCH] Add a function that resets the pointer and deletes the object pointed to git-svn-id: https://svn.dealii.org/trunk@22695 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/base/smartpointer.h | 24 +++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/deal.II/include/deal.II/base/smartpointer.h b/deal.II/include/deal.II/base/smartpointer.h index 4f3bd1b873..36621b14ec 100644 --- a/deal.II/include/deal.II/base/smartpointer.h +++ b/deal.II/include/deal.II/base/smartpointer.h @@ -1,8 +1,7 @@ //--------------------------------------------------------------------------- // $Id$ -// Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -157,6 +156,12 @@ class SmartPointer */ SmartPointer & operator= (const SmartPointer &tt); + /** + * Delete the object pointed to + * and set the pointer to zero. + */ + void clear (); + /** * Conversion to normal pointer. */ @@ -315,6 +320,21 @@ SmartPointer::~SmartPointer () +template +inline +void +SmartPointer::clear () +{ + if (t != 0) + { + t->unsubscribe(id); + delete t; + t = 0; + } +} + + + template inline SmartPointer & SmartPointer::operator = (T *tt) -- 2.39.5