$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-users] [Smart Pointers] enable_shared_from_this::shared_from_this() behaviour query
From: eddyaod_at_[hidden]
Date: 2011-06-12 22:03:27
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>(); } )
}