From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-02-21 10:57:09
Rodolfo Lima wrote:
> I miss a custom destructor version of shared_from_this. The only one
> function just accepts a pointer and construct a shared_ptr from it.
> Should shared_from_this also match shared_ptr's constructor that
> takes a pointer
> and it's destructor function object, or the lack of it is a design
It is a design decision. shared_from_this is not a constructor. It it
intended to obtain a shared_ptr to an object that is already being managed
by another shared_ptr.
> I know I could use de constructor directly, but I prefer using
> shared_from_this because this way it's more explicit that we're
> the boundary" between raw pointer and smart_pointer.
You might want to write your own helper functions based on the shared_ptr
constructors. The free function shared_from_this was an experimental feature
and will not be part of the next Boost release. A helper class template
enable_shared_from_this supplies a member function with the same name that
takes no arguments and (this time really) returns a shared_ptr to this.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk