1 | #include <boost/config.hpp> |
2 | |
3 | #ifndef BOOST_MSVC |
4 | |
5 | int main() |
6 | { |
7 | } |
8 | |
9 | #else |
10 | |
11 | // |
12 | // mem_fn_cdecl_ref_test.cpp - reference_wrapper, cdecl |
13 | // |
14 | // Copyright 2009, 2024 Peter Dimov |
15 | // |
16 | // Distributed under the Boost Software License, Version 1.0. |
17 | // See accompanying file LICENSE_1_0.txt or copy at |
18 | // http://www.boost.org/LICENSE_1_0.txt |
19 | // |
20 | |
21 | #define BOOST_MEM_FN_ENABLE_CDECL |
22 | |
23 | #include <boost/mem_fn.hpp> |
24 | #include <boost/ref.hpp> |
25 | #include <boost/core/lightweight_test.hpp> |
26 | |
27 | struct X |
28 | { |
29 | int __cdecl f0() { return 1; } |
30 | int __cdecl g0() const { return -1; } |
31 | |
32 | int __cdecl f1( int x1 ) { return x1; } |
33 | int __cdecl g1( int x1 ) const { return -x1; } |
34 | |
35 | int __cdecl f2( int x1, int x2 ) { return x1+x2; } |
36 | int __cdecl g2( int x1, int x2 ) const { return -x1-x2; } |
37 | |
38 | int __cdecl f3( int x1, int x2, int x3 ) { return x1+x2+x3; } |
39 | int __cdecl g3( int x1, int x2, int x3 ) const { return -x1-x2-x3; } |
40 | }; |
41 | |
42 | int main() |
43 | { |
44 | X x; |
45 | |
46 | BOOST_TEST_EQ( boost::mem_fn( &X::f0 )( boost::ref( x ) ), 1 ); |
47 | BOOST_TEST_EQ( boost::mem_fn( &X::g0 )( boost::cref( x ) ), -1 ); |
48 | |
49 | BOOST_TEST_EQ( boost::mem_fn( &X::f1 )( boost::ref( x ), 1 ), 1 ); |
50 | BOOST_TEST_EQ( boost::mem_fn( &X::g1 )( boost::cref( x ), 1 ), -1 ); |
51 | |
52 | BOOST_TEST_EQ( boost::mem_fn( &X::f2 )( boost::ref( x ), 1, 2 ), 1+2 ); |
53 | BOOST_TEST_EQ( boost::mem_fn( &X::g2 )( boost::cref( x ), 1, 2 ), -1-2 ); |
54 | |
55 | BOOST_TEST_EQ( boost::mem_fn( &X::f3 )( boost::ref( x ), 1, 2, 3 ), 1+2+3 ); |
56 | BOOST_TEST_EQ( boost::mem_fn( &X::g3 )( boost::cref( x ), 1, 2, 3 ), -1-2-3 ); |
57 | |
58 | return boost::report_errors(); |
59 | } |
60 | |
61 | #endif |
62 | |