
Andrey Semashev:
Is the ticket 2126:
http://svn.boost.org/trac/boost/ticket/2126
actually fixed in trunk? The ticket is still open, but my code that uses enable_shared_from_this and make_shared runs fine on trunk.
Interesting. No, I don't believe that trunk is OK. The constructor support just masks the problem. Try for example the following test: #include <boost/shared_ptr.hpp> #include <boost/enable_shared_from_this.hpp> #include <boost/make_shared.hpp> #include <boost/detail/lightweight_test.hpp> struct X: boost::enable_shared_from_this<X> { bool destroyed_; X(): destroyed_( false ) {} ~X() { destroyed_ = true; } }; int main() { boost::shared_ptr<X> px = boost::make_shared<X>(); boost::shared_ptr<X> px2 = px->shared_from_this(); BOOST_TEST( px == px2 ); BOOST_TEST( !( px < px2 ) && !( px2 < px ) ); px.reset(); BOOST_TEST( !px2->destroyed_ ); return boost::report_errors(); }