|
Boost : |
Subject: Re: [boost] enable_shared_from_this2
From: Peter Dimov (pdimov_at_[hidden])
Date: 2009-10-28 09:40:05
Berserker wrote:
>> I remember now. But I thought I had fixed it. In this message I say:
>> and, in fact, the code in the trunk and in the release branch already
>> does this:
>
> That's right but please have a look at my test example. You can comment
> out the constructor stuffs and try to switch from enable_shared_from_this
> and enable_shared_from_this2: there are other cases where it fails
> (shared_ptrs reinitialization in particular).
All of your tests rely on the constructor stuff... if by reinitialization
you mean something like
#include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/detail/lightweight_test.hpp>
//
class X: public boost::enable_shared_from_this<X>
{
};
void null_deleter( void const* )
{
}
void test( X & x )
{
boost::shared_ptr<X> px( &x, null_deleter );
try
{
boost::shared_ptr< X > qx = px->shared_from_this();
BOOST_TEST( px == qx );
BOOST_TEST( !( px < qx ) && !( qx < px ) );
}
catch( boost::bad_weak_ptr const& )
{
BOOST_ERROR( "px->shared_from_this() failed" );
}
}
int main()
{
X x;
test( x );
test( x );
return boost::report_errors();
}
then it passes.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk