]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/weak_from_this_test.cpp
b090cbc0411f31d5daf3ce3d8be1e3a0b70be6ec
1 #include <boost/config.hpp>
4 // weak_from_this_test.cpp
6 // Copyright (c) 2002, 2003, 2015 Peter Dimov
8 // 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/weak_ptr.hpp>
18 #include <boost/detail/lightweight_test.hpp>
20 class V
: public boost::enable_shared_from_this
<V
>
26 boost::shared_ptr
<V
> p( new V
);
28 boost::weak_ptr
<V
> q
= p
;
29 BOOST_TEST( !q
.expired() );
31 boost::weak_ptr
<V
> q2
= p
->weak_from_this();
32 BOOST_TEST( !q2
.expired() );
33 BOOST_TEST( !(q
< q2
) && !(q2
< q
) );
37 boost::weak_ptr
<V
> q3
= v2
.weak_from_this();
38 BOOST_TEST( q3
.expired() );
42 boost::weak_ptr
<V
> q4
= p
->weak_from_this();
43 BOOST_TEST( !q4
.expired() );
44 BOOST_TEST( !(q
< q4
) && !(q4
< q
) );
45 BOOST_TEST( !(q2
< q4
) && !(q4
< q2
) );
51 return boost::report_errors();