Boost logo

Boost :

From: Frank Mori Hess (fmhess_at_[hidden])
Date: 2008-03-17 01:42:49


On Monday 17 March 2008 01:36, Frank Mori Hess wrote:
> The implementation I've got in mind (haven't actually tried it yet)
> would work as follows. I'd add two shared_ptrs to
> enable_shared_from_this, call them "internal_shared" and
> "external_shared". external_shared would be assigned the external
> shared_ptr which first takes ownership of *this. internal_shared would
> be initialized with the "this" pointer, and a custom deleter which would
> reset external_shared. internal_shared would be reset right after
> external_shared is initialized (when an external shared_ptr takes
> ownership of *this). Any calls to shared_from_this() that occur prior
> to an external shared_ptr taking ownership of *this (such as in the
> constructor) would get a copy of internal_shared.

Hmm, actually nevermind. This scheme isn't good enough yet, as I'd also
want a weak_ptr copy of internal_shared to recognize the case where the
object is still being kept alive by a copy of external_shared.

-- 
Frank



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk