]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/esft_void_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / smart_ptr / test / esft_void_test.cpp
1 //
2 // esft_void_test.cpp
3 //
4 // Copyright 2009 Peter Dimov
5 //
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
9 //
10
11
12 #include <boost/enable_shared_from_this.hpp>
13 #include <boost/shared_ptr.hpp>
14 #include <boost/detail/lightweight_test.hpp>
15
16 //
17
18 class X: public boost::enable_shared_from_this<X>
19 {
20 };
21
22 int main()
23 {
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 );
27
28 try
29 {
30 boost::shared_ptr< X > qx = px->shared_from_this();
31
32 BOOST_TEST( px == qx );
33 BOOST_TEST( !( px < qx ) && !( qx < px ) );
34 }
35 catch( boost::bad_weak_ptr const& )
36 {
37 BOOST_ERROR( "px->shared_from_this() failed" );
38 }
39
40 return boost::report_errors();
41 }