Re: Who's responsible for deletion?

From: Jonathan M. Gilligan (jonathan.gilligan@vanderbilt.edu)
Date: Mon Sep 14 1998 - 21:18:17 MEST


There is a fairly extensive literature on reference-counted objects (and
smart pointers). I would recommend Scott Myers's discussion in Effective
C++ and also the implementation in the Visualization Toolkit
(http://www.kitware.com/vtk and the discussion of these in the
Visualization Toolkit book by W. Schroeder, B. Lorensen, and K. Martin) as
good starting points. I think James Coplein discussed this in Advanced C++
Idioms, but it's been a while since I've read that and I can't remember the
details of his treatment.

This pattern is perhaps orthogonal to your problem (deleting all references
upon object destruction), but would at least prevent deleting or destroying
an object while there are live references to it.

Hope some of this helps,
Jonathan

At 04:56 AM 9/14/98 -0500, Valery Fine wrote:
>On 14 Sep 98 at 10:22, Patrick Schemitz wrote:
>
>
>> Doesn't the destructor remove them from the containers?
>
>  No it doesn't. Since the object has not "backward pointer to the 
>container ('s !).
>
>  This means to be "right" ROOT (and any other C++ program too) must 
>scan ALL containers created to find out whether the deleted object 
>did belong one of them. But the last means one has to create the list 
>of all containers as well etc etc etc. It is some of the "well-known"
>problem of C++.
>
>                  Valery
>=================================================================
>Dr. Valeri Faine (Fine)
>    -------------------          Phone: +1 516 344 7806
>Brookhaven National Laboratory   FAX  : +1 516 344 4206
>Bldg. 510A /STAR                 mailto:fine@bnl.gov
>Upton, New York, 11973-5000      http://nicewww.cern.ch/~fine
>USA
>                                 
>Dr. Valery Fine                  Telex : 911621 dubna su
>    -----------
>LCTA/Joint Inst.for Nuclear Res. Phone : +7 09621 6 40 80
>141980 Dubna, Moscow region      Fax   : +7 09621 6 51 45
>Russia                           mailto:fine@main1.jinr.dubna.su             
>                 
>

===========================================================================
Jonathan M. Gilligan                     <jonathan.gilligan@vanderbilt.edu>
Research Assistant Professor and Associate Director          (615) 343-2957
Center for Molecular and Atomic Studies at Surfaces           Fax: 343-1708
Dept. of Physics and Astronomy, Box 1807-B                   Sec'y 322-6438
Vanderbilt University, Nashville, TN 37235                    Lab: 343-7578



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:37 MET