From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-03-18 16:57:53
Frank Mori Hess:
> Yes, I think it does break get_deleter(), I hadn't considered that. It's
> because all the shared_ptrs created by shared_from_this() before the
> is owned by the user's shared_ptr need to be made consistent with the
> shared_count in the user's shared_ptr. The ethical course would have been
> take the shared_count from the user's shared_ptr and copy it into any
> preexisting shared_ptrs created by shared_from_this(). However, there may
> many of those, and there was no list of references to them available. So
> took the practical course, and went the opposite direction by copying a
> shared_count from the preexisting shared_ptrs into the user's shared_ptr
> which there is only one, and which has a handy reference available).
My current line of thinking is that we should refrain from introducing
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.
Is it really that important to make the shared_ptr instances created in X::X
share ownership with px?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk