I have to register an object in a container upon its creation. Without smart pointers I\'d use something like this:
a_class::a_class()
{
register_somewhere(t
For this purpose, I wrote my own drop-in replacement for shared_ptr
, weak_ptr
and enable_shared_from_this
. You can check it out at Sourceforge.
It allows call of shared_from_this()
in constructor and destructor without helper functions without space overhead compared to the standard enable_shared_from_this.
Note: creating shared_ptr's in dtors is only allowed as long as they are created only temporarily. That is, they are being destroyed before the dtor returns.