From: David Abrahams (abrahams_at_[hidden])
Date: 2001-01-09 11:35:55
----- Original Message -----
From: "Andrew Green" <ag_at_[hidden]>
Sent: Tuesday, January 09, 2001 11:05 AM
Subject: Re: [boost] Re: uncounted_ptr
> David Abrahams wrote:
> > Actually, what I've mostly wanted was a way to keep garbage-collectable
> > in a kind of cache without preventing it from being collected. This is
> > loosely related to weak_ptr.
> One technique I've had success with is modifying the behavior of a
> counted_ptr so that it invokes an appropriate 'finalize' function, in my
> case usually a virtual method on the object in question, but that's not
> crucial to the idea. The finalize method can just delete the now
> un-referenced object, or it can move it into a cache.
In my case, the data needs to be in the cache all the time, not just when
it's no longer referenced from anywhere else. Furthermore, GC ought to be
able to collect it even when it's in the cache. That's when you need the
weak pointer - to signal to the cache that the data is gone.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk