13 Jun
2011
13 Jun
'11
2:03 a.m.
shared_from_this() throws bad_weak_ptr if it's called in a derived destructor even if the object is heap allocated, does anyone know if this is intended? And if so, why? Example: class DestructorCheck : public std::tr1::enable_shared_from_this <DestructorCheck> { public: DestructorCheck() { } ~DestructorCheck() { shared_from_this(); } }; BOOST_AUTO_TEST_CASE(enable_weakTests) { BOOST_CHECK_THROW( { DestructorCheck d; } , std::tr1::bad_weak_ptr ) BOOST_CHECK_NO_THROW( { std::tr1::shared_ptr<DestructorCheck> d = boost::make_shared<DestructorCheck>(); } ) }