From: Guido Kanschat Date: Thu, 11 Nov 2010 21:07:28 +0000 (+0000) Subject: Add a function that resets the pointer and deletes the object pointed to X-Git-Tag: v8.0.0~4962 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66119eb461a99195b33601701c738d9d7eefbe5a;p=dealii.git 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 --- 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)