From -8900827358854171636
X-Google-Thread: f78e5,480a31feed3c6a1b
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news3.google.com!newshub.sdsu.edu!cyclone.bc.net!news.alt.net!comp-std-cpp-robomod!not-for-mail
From: Larry Evans <cppljevans@cox-internet.com>
Newsgroups: comp.std.c++
Subject: Re: boost::shared_ptr revisited again
Date: 10 Jun 2005 15:40:14 GMT
Organization: Cox Communications
Lines: 26
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <aVhqe.12170$mC.10860@okepread07>
References: <4299DE64.40403@poczta.onet.pl> <3g55jqFajuhcU1@news.dfncis.de> <d7o5b6$3g3$1@nemesis.news.tpi.pl> <ou0oe.1880$wy1.4@newssvr13.news.prodigy.com> <S4Odne3eN6s1Cj3fRVn-2g@giganews.com> <IHMn9C.1CM1@beaver.cs.washington.edu> <AoWdnSlmv52dxDnfRVn-oA@giganews.com> <1118144437.192255.257840@g47g2000cwa.googlegroups.com> <k4ydnemTlqhbRjjfRVn-rw@rcn.net> <IHr3K9.1KJs@beaver.cs.washington.edu> <pxb4qc9tjt0.fsf@news.bourguet.org> <IHsD6v.xM4@beaver.cs.washington.edu> <878y1j9syu.fsf@news.bourguet.org> <I <42A95896.4030406@moderncppdesign.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Delivered-To: std-c++@ucar.edu
X-Authentication-Warning: okepread07.mgt.cox.net: news set sender to newsmaster@cox.net using -f
User-Agent: Debian Thunderbird 1.0 (X11/20050116)
X-Accept-Language: en-us, en
X-Complaints-To: abuse@cox.net
X-Trace: okepread07 1118415558 24.250.158.183 (Fri, 10 Jun 2005 10:59:18 EDT)
NNTP-Posting-Date: Fri, 10 Jun 2005 10:59:18 EDT
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
Xref: g2news1.google.com comp.std.c++:5064

On 06/10/2005 09:00 AM, Andrei Alexandrescu wrote:
[snip]
> The programmer can choose to implement dispose() or 
> idunneedthisdudeanymore() or whatnot to make the state of the object a 
> violation of its invariant (e.g., a date with all fields -1). I 
> personally think a nicer practice is to put the object in a "valid, but 
> uninteresting state". But in a memory-safe language like Java, nobody 
I'm wondering if this isn't very much like polaris' zombie:

   http://polaris.cs.uiuc.edu/polaris/polaris_developer/node42.html

what happens is that the original referent type has a virtual function,
is_valid which indicates it's valid.  Each deref of the referent checks
this to see if it is a valid referent.  After all strong smart pointers
to the referent are gone; yet, there are still weak smart pointers to
the referent, the referent is transformed, via placement new, into a
"zombie" whose is_valid indicates it's no longer valid.  Of course this
requires each refcounted object to be derived from an abstract base
class with pure virtual is_valid, but it does save debug time.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



