]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_test.cpp
1 #include <boost/config.hpp>
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
11 // bind_void_test.cpp - test for bind<void>
13 // Copyright (c) 2008 Peter Dimov
14 // Copyright (c) 2014 Agustin Berge
16 // Distributed under the Boost Software License, Version 1.0. (See
17 // accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
21 #include <boost/bind.hpp>
22 #include <boost/ref.hpp>
24 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
25 #pragma warning(push, 3)
30 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
34 #include <boost/detail/lightweight_test.hpp>
42 return global_result
= 17041L;
47 return global_result
= a
;
50 long f_2(long a
, long b
)
52 return global_result
= a
+ 10 * b
;
55 long f_3(long a
, long b
, long c
)
57 return global_result
= a
+ 10 * b
+ 100 * c
;
60 long f_4(long a
, long b
, long c
, long d
)
62 return global_result
= a
+ 10 * b
+ 100 * c
+ 1000 * d
;
65 long f_5(long a
, long b
, long c
, long d
, long e
)
67 return global_result
= a
+ 10 * b
+ 100 * c
+ 1000 * d
+ 10000 * e
;
70 long f_6(long a
, long b
, long c
, long d
, long e
, long f
)
72 return global_result
= a
+ 10 * b
+ 100 * c
+ 1000 * d
+ 10000 * e
+ 100000 * f
;
75 long f_7(long a
, long b
, long c
, long d
, long e
, long f
, long g
)
77 return global_result
= a
+ 10 * b
+ 100 * c
+ 1000 * d
+ 10000 * e
+ 100000 * f
+ 1000000 * g
;
80 long f_8(long a
, long b
, long c
, long d
, long e
, long f
, long g
, long h
)
82 return global_result
= a
+ 10 * b
+ 100 * c
+ 1000 * d
+ 10000 * e
+ 100000 * f
+ 1000000 * g
+ 10000000 * h
;
85 long f_9(long a
, long b
, long c
, long d
, long e
, long f
, long g
, long h
, long i
)
87 return global_result
= a
+ 10 * b
+ 100 * c
+ 1000 * d
+ 10000 * e
+ 100000 * f
+ 1000000 * g
+ 10000000 * h
+ 100000000 * i
;
92 using namespace boost
;
96 BOOST_TEST( (bind
<void>(f_0
)(i
), (global_result
== 17041L)) );
97 BOOST_TEST( (bind
<void>(f_1
, _1
)(i
), (global_result
== 1L)) );
98 BOOST_TEST( (bind
<void>(f_2
, _1
, 2)(i
), (global_result
== 21L)) );
99 BOOST_TEST( (bind
<void>(f_3
, _1
, 2, 3)(i
), (global_result
== 321L)) );
100 BOOST_TEST( (bind
<void>(f_4
, _1
, 2, 3, 4)(i
), (global_result
== 4321L)) );
101 BOOST_TEST( (bind
<void>(f_5
, _1
, 2, 3, 4, 5)(i
), (global_result
== 54321L)) );
102 BOOST_TEST( (bind
<void>(f_6
, _1
, 2, 3, 4, 5, 6)(i
), (global_result
== 654321L)) );
103 BOOST_TEST( (bind
<void>(f_7
, _1
, 2, 3, 4, 5, 6, 7)(i
), (global_result
== 7654321L)) );
104 BOOST_TEST( (bind
<void>(f_8
, _1
, 2, 3, 4, 5, 6, 7, 8)(i
), (global_result
== 87654321L)) );
105 BOOST_TEST( (bind
<void>(f_9
, _1
, 2, 3, 4, 5, 6, 7, 8, 9)(i
), (global_result
== 987654321L)) );
112 short operator()(short & r
) const { return global_result
= ++r
; }
113 int operator()(int a
, int b
) const { return global_result
= a
+ 10 * b
; }
114 long operator() (long a
, long b
, long c
) const { return global_result
= a
+ 10 * b
+ 100 * c
; }
115 void operator() (long a
, long b
, long c
, long d
) const { global_result
= a
+ 10 * b
+ 100 * c
+ 1000 * d
; }
118 void function_object_test()
120 using namespace boost
;
126 BOOST_TEST( (bind
<void>(Y(), ref(i
))(), (global_result
== 7)) );
127 BOOST_TEST( (bind
<void>(Y(), ref(i
))(), (global_result
== 8)) );
128 BOOST_TEST( (bind
<void>(Y(), i
, _1
)(k
), (global_result
== 38)) );
129 BOOST_TEST( (bind
<void>(Y(), i
, _1
, 9)(k
), (global_result
== 938)) );
130 BOOST_TEST( (bind
<void>(Y(), i
, _1
, 9, 4)(k
), (global_result
== 4938)) );
136 function_object_test();
138 return boost::report_errors();