4 // Copyright 2009 Peter Dimov
6 // Distributed under the Boost Software License, Version 1.0.
7 // See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt
12 #include <boost/enable_shared_from_this.hpp>
13 #include <boost/shared_ptr.hpp>
14 #include <boost/detail/lightweight_test.hpp>
18 class X: public boost::enable_shared_from_this<X>
24 boost::shared_ptr< void const volatile > pv( new X );
25 boost::shared_ptr< void > pv2 = boost::const_pointer_cast< void >( pv );
26 boost::shared_ptr< X > px = boost::static_pointer_cast< X >( pv2 );
30 boost::shared_ptr< X > qx = px->shared_from_this();
32 BOOST_TEST( px == qx );
33 BOOST_TEST( !( px < qx ) && !( qx < px ) );
35 catch( boost::bad_weak_ptr const& )
37 BOOST_ERROR( "px->shared_from_this() failed" );
40 return boost::report_errors();