Boost logo

Boost :

From: Frank Mori Hess (fmhess_at_[hidden])
Date: 2007-12-23 20:57:35

On Sunday 23 December 2007 11:12, Robert Sitton wrote:
> I've had a few cases where my design required calling
> shared_from_this() in a constructor and destructor. I made some
> modifications to enable_shared_from_this which I have posted here:
> There is a test function in a test file in the zip archive that will
> fail if you call shared_from_this() instead of my
> ctor_shared_from_this() method.

But it just creates a shared_ptr with a null deleter in the constructor. I
don't see how it adds anything over just using a raw pointer, since the
shared_ptr in the constructor will have no relation to the external
shared_ptr which will actually own the object after it is constructed. To
do that, you would need to something along the lines of storing a copy of
the shared_ptr inside the object until it is passed over to an external
shared_ptr that really owns the object. Or, use a post-constructor and
get the shared_ptr there, which is what I tried to support with


Boost list run by bdawes at, gregod at, cpdaniel at, john at