Boost logo

Boost :

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
> done
> because all the shared_ptrs created by shared_from_this() before the
> object
> 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
> to
> 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
> be
> many of those, and there was no list of references to them available. So
> I
> 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
> (of
> which there is only one, and which has a handy reference available).

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.

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, gregod at, cpdaniel at, john at