|
Boost : |
From: Frank Mori Hess (fmhess_at_[hidden])
Date: 2008-03-18 22:28:15
On Tuesday 18 March 2008 16:57, Peter Dimov wrote:
> My current line of thinking is that we should refrain from introducing
> regressions. After
>
> shared_ptr<X> px( new X, d );
>
> px should contain the deleter d and - in the case when shared_from_this
> hasn't been called in the constructor - px.use_count() should be 1.
The use_count() is 1 with the patched version too, there's no regression
there. _internal_shared_this is reset when px is constructed, so it
doesn't inflate the use_count. By the way, I think I understand now what
you were saying before about not seeing the need for 2 shared_ptrs in
enable_shared_from_this. Since _internal_shared_this is only used from
construction until ownership is transferred to a shared_ptr, and
_user_deleter is only used after ownership is transferred, it can probably
be optimized so that a single shared_ptr object fulfills both roles.
> Is it really that important to make the shared_ptr instances created in
> X::X share ownership with px?
It is to me, as that is my primary motivation for making this patch. If
they didn't share ownership I wouldn't bother with it, since the plain
old "this" pointer would do just as well.
-- Frank
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk