
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: http://lists.boost.org/Archives/boost/2008/04/135372.php
but this makes 3 tests fail. Looking at these tests, I don't see why they should be legal:
In esft_constructor_test.cpp, line 143, X initializes early_px by calling shared_from_this, but X is never passed to a shared_ptr which then owns it. From what I understand, this should be illegal.
The next problem is esft_constructor_test.cpp, line 160. y.shared_from_this() returns a shared_ptr, but again, no shared_ptr takes ownership of Y later. While shared_from_this() is not called from the ctor, I wonder if this is yet another use case or just an accident.
The test case in shared_from_this_test.cpp, line 135 is similar.
-- Frank