Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-04-28 09:27:45


Daniel Frey:
> Consider:
>
> class Object {
> static map< string, shared_ptr< Object > > cache;
>
> Object()
> {
> cache.insert( make_pair( "foo", shared_from_this() ) );
> throw 42;
> }
> };
>
> With the above BOOST_ASSERT(_shared_count.empty()), ::abort() seems to
> most sensible thing we can do, otherwise it would lead to very dangerous
> situations where cache contains a shared_ptr to a deleted object.

The original assert catches this case, does it not?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk