2 // esft_second_ptr_test.cpp
4 // This test has been extracted from a real
5 // scenario that occurs in Boost.Python
7 // Copyright 2009 Peter Dimov
9 // Distributed under the Boost Software License, Version 1.0.
10 // See accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt
15 #include <boost/enable_shared_from_this.hpp>
16 #include <boost/shared_ptr.hpp>
17 #include <boost/detail/lightweight_test.hpp>
21 class X: public boost::enable_shared_from_this<X>
25 void null_deleter( void const* )
31 boost::shared_ptr<X> px( new X );
34 boost::shared_ptr<X> px2( px.get(), null_deleter );
35 BOOST_TEST( px == px2 );
40 boost::shared_ptr< X > qx = px->shared_from_this();
42 BOOST_TEST( px == qx );
43 BOOST_TEST( !( px < qx ) && !( qx < px ) );
45 catch( boost::bad_weak_ptr const& )
47 BOOST_ERROR( "px->shared_from_this() failed" );
50 return boost::report_errors();