
On Sun, 2008-04-27 at 20:27 -0400, Frank Mori Hess wrote:
On Sunday 27 April 2008 15:02, Daniel Frey wrote:
My questions result from the observation that in the virtual dtor of enable_shared_from_this, I tried BOOST_ASSERT( _shared_count.empty() ),
Are you aware that will abort the program in the case of a derived constructor calling shared_from_this() then throwing? It might be worth considering making it a requirement that no constructor can throw after calling shared_from_this though, see the first half of an earlier post:
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. Regards, Daniel