]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/shared_from_raw_test4.cpp
2 // shared_from_raw_test4 - based on esft_void_test.cpp
4 // Copyright 2009, 2014 Peter Dimov
6 // Distributed under the Boost Software License, Version 1.0.
8 // See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt
13 #include <boost/smart_ptr/enable_shared_from_raw.hpp>
14 #include <boost/shared_ptr.hpp>
15 #include <boost/core/lightweight_test.hpp>
19 class X
: public boost::enable_shared_from_raw
25 boost::shared_ptr
< void const volatile > pv( new X
);
26 boost::shared_ptr
< void > pv2
= boost::const_pointer_cast
< void >( pv
);
27 boost::shared_ptr
< X
> px
= boost::static_pointer_cast
< X
>( pv2
);
31 boost::shared_ptr
< X
> qx
= boost::shared_from_raw( px
.get() );
33 BOOST_TEST( px
== qx
);
34 BOOST_TEST( !( px
< qx
) && !( qx
< px
) );
36 catch( boost::bad_weak_ptr
const& )
38 BOOST_ERROR( "shared_from_this( px.get() ) failed" );
41 boost::shared_ptr
< X
const volatile > px2( px
);
45 boost::shared_ptr
< X
const volatile > qx2
= boost::shared_from_raw( px2
.get() );
47 BOOST_TEST( px2
== qx2
);
48 BOOST_TEST( !( px2
< qx2
) && !( qx2
< px2
) );
50 catch( boost::bad_weak_ptr
const& )
52 BOOST_ERROR( "shared_from_this( px2.get() ) failed" );
55 return boost::report_errors();