]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/bind/test/mem_fn_dm_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / bind / test / mem_fn_dm_test.cpp
1 #include <boost/config.hpp>
2
3 #if defined(BOOST_MSVC)
4 #pragma warning(disable: 4786) // identifier truncated in debug info
5 #pragma warning(disable: 4710) // function not inlined
6 #pragma warning(disable: 4711) // function selected for automatic inline expansion
7 #pragma warning(disable: 4514) // unreferenced inline removed
8 #endif
9
10 //
11 // mem_fn_dm_test.cpp - data members
12 //
13 // Copyright (c) 2005 Peter Dimov
14 //
15 // Distributed under the Boost Software License, Version 1.0. (See
16 // accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
18 //
19
20 #include <boost/mem_fn.hpp>
21
22 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
23 #pragma warning(push, 3)
24 #endif
25
26 #include <iostream>
27
28 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
29 #pragma warning(pop)
30 #endif
31
32 #include <boost/detail/lightweight_test.hpp>
33
34 struct X
35 {
36 int m;
37 };
38
39 int main()
40 {
41 X x = { 0 };
42
43 boost::mem_fn( &X::m )( x ) = 401;
44
45 BOOST_TEST( x.m == 401 );
46 BOOST_TEST( boost::mem_fn( &X::m )( x ) == 401 );
47
48 boost::mem_fn( &X::m )( &x ) = 502;
49
50 BOOST_TEST( x.m == 502 );
51 BOOST_TEST( boost::mem_fn( &X::m )( &x ) == 502 );
52
53 X * px = &x;
54
55 boost::mem_fn( &X::m )( px ) = 603;
56
57 BOOST_TEST( x.m == 603 );
58 BOOST_TEST( boost::mem_fn( &X::m )( px ) == 603 );
59
60 X const & cx = x;
61 X const * pcx = &x;
62
63 BOOST_TEST( boost::mem_fn( &X::m )( cx ) == 603 );
64 BOOST_TEST( boost::mem_fn( &X::m )( pcx ) == 603 );
65
66 return boost::report_errors();
67 }