]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/sp_unary_addr_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / smart_ptr / test / sp_unary_addr_test.cpp
1 //
2 // sp_unary_addr_test.cpp
3 //
4 // Copyright (c) 2007 Peter Dimov
5 //
6 // Distributed under the Boost Software License, Version 1.0. (See
7 // accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 //
10
11 #include <boost/shared_ptr.hpp>
12 #include <boost/detail/lightweight_test.hpp>
13 #include <memory>
14
15 struct deleter
16 {
17 private:
18
19 void operator& ();
20 void operator& () const;
21
22 public:
23
24 int data;
25
26 deleter(): data( 17041 )
27 {
28 }
29
30 void operator()( void * )
31 {
32 }
33 };
34
35 struct X
36 {
37 };
38
39 int main()
40 {
41 X x;
42
43 {
44 boost::shared_ptr<X> p( &x, deleter() );
45
46 deleter * q = boost::get_deleter<deleter>( p );
47
48 BOOST_TEST( q != 0 );
49 BOOST_TEST( q != 0 && q->data == 17041 );
50 }
51
52 #if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1300 )
53 #else
54
55 {
56 boost::shared_ptr<X> p( &x, deleter(), std::allocator<X>() );
57
58 deleter * q = boost::get_deleter<deleter>( p );
59
60 BOOST_TEST( q != 0 );
61 BOOST_TEST( q != 0 && q->data == 17041 );
62 }
63
64 #endif
65
66 return boost::report_errors();
67 }