
On Wed, 2008-04-30 at 20:34 +0300, Peter Dimov wrote:
We first need to decide which one we want to test for. The new behavior looks slightly better to me; when two shared_ptr instances take ownership of the same object, it's likely that the first one is the "legitimate" owner and the second one uses a null deleter.
I also prefer that an update of the internal _weak_ptr only happens when the object is currently not owned. Otherwise, I think we might also run into scoping problems like this: struct X : enable_shared_from_this<X> {}; shared_ptr<X> x1( new X() ); x1->shared_from_this(); // OK { shared_ptr<X> x2( x1.get(), null_deleter() ); x2->shared_from_this(); // OK } x1->shared_from_this(); // throws bad_weak_ptr... Regards, Daniel