]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_const_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / phoenix / test / boost_bind_compatibility / bind_const_test.cpp
1 /*==============================================================================
2 Copyright (c) 2001-2004 Peter Dimov and Multi Media Ltd.
3 Copyright (c) 2001 David Abrahams
4 Copyright (c) 2005-2010 Joel de Guzman
5 Copyright (c) 2010 Thomas Heller
6
7 Distributed under the Boost Software License, Version 1.0. (See accompanying
8 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 ==============================================================================*/
10
11 #include <boost/config.hpp>
12
13 #if defined(BOOST_MSVC)
14 #pragma warning(disable: 4786) // identifier truncated in debug info
15 #pragma warning(disable: 4710) // function not inlined
16 #pragma warning(disable: 4711) // function selected for automatic inline expansion
17 #pragma warning(disable: 4514) // unreferenced inline removed
18 #endif
19
20 #include <boost/phoenix/core.hpp>
21 #include <boost/phoenix/bind.hpp>
22
23 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
24 #pragma warning(push, 3)
25 #endif
26
27 #include <iostream>
28
29 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
30 #pragma warning(pop)
31 #endif
32
33 #include <boost/detail/lightweight_test.hpp>
34
35 //
36
37 long f_0()
38 {
39 return 17041L;
40 }
41
42 long f_1(long a)
43 {
44 return a;
45 }
46
47 long f_2(long a, long b)
48 {
49 return a + 10 * b;
50 }
51
52 long f_3(long a, long b, long c)
53 {
54 return a + 10 * b + 100 * c;
55 }
56
57 long f_4(long a, long b, long c, long d)
58 {
59 return a + 10 * b + 100 * c + 1000 * d;
60 }
61
62 long f_5(long a, long b, long c, long d, long e)
63 {
64 return a + 10 * b + 100 * c + 1000 * d + 10000 * e;
65 }
66
67 long f_6(long a, long b, long c, long d, long e, long f)
68 {
69 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
70 }
71
72 long f_7(long a, long b, long c, long d, long e, long f, long g)
73 {
74 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
75 }
76
77 long f_8(long a, long b, long c, long d, long e, long f, long g, long h)
78 {
79 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
80 }
81
82 long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
83 {
84 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
85 }
86
87 long global_result;
88
89 void fv_0()
90 {
91 global_result = 17041L;
92 }
93
94 void fv_1(long a)
95 {
96 global_result = a;
97 }
98
99 void fv_2(long a, long b)
100 {
101 global_result = a + 10 * b;
102 }
103
104 void fv_3(long a, long b, long c)
105 {
106 global_result = a + 10 * b + 100 * c;
107 }
108
109 void fv_4(long a, long b, long c, long d)
110 {
111 global_result = a + 10 * b + 100 * c + 1000 * d;
112 }
113
114 void fv_5(long a, long b, long c, long d, long e)
115 {
116 global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e;
117 }
118
119 void fv_6(long a, long b, long c, long d, long e, long f)
120 {
121 global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
122 }
123
124 void fv_7(long a, long b, long c, long d, long e, long f, long g)
125 {
126 global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
127 }
128
129 void fv_8(long a, long b, long c, long d, long e, long f, long g, long h)
130 {
131 global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
132 }
133
134 void fv_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
135 {
136 global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
137 }
138
139 template<class F, class A> long tester(F const & f, A const & a)
140 {
141 return f(a);
142 }
143
144 template<class F, class A> long testerv(F const & f, A const & a)
145 {
146 f(a);
147 return global_result;
148 }
149
150 void function_test()
151 {
152 using boost::phoenix::bind;
153 using boost::phoenix::placeholders::_1;
154
155 int const i = 1;
156
157 BOOST_TEST( tester( bind(f_0), i ) == 17041L );
158 BOOST_TEST( tester( bind(f_1, _1), i ) == 1L );
159 BOOST_TEST( tester( bind(f_2, _1, 2), i ) == 21L );
160 BOOST_TEST( tester( bind(f_3, _1, 2, 3), i ) == 321L );
161 BOOST_TEST( tester( bind(f_4, _1, 2, 3, 4), i ) == 4321L );
162 BOOST_TEST( tester( bind(f_5, _1, 2, 3, 4, 5), i ) == 54321L );
163 BOOST_TEST( tester( bind(f_6, _1, 2, 3, 4, 5, 6), i ) == 654321L );
164 BOOST_TEST( tester( bind(f_7, _1, 2, 3, 4, 5, 6, 7), i ) == 7654321L );
165 BOOST_TEST( tester( bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8), i ) == 87654321L );
166 BOOST_TEST( tester( bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9), i ) == 987654321L );
167
168 BOOST_TEST( testerv( bind(fv_0), i ) == 17041L );
169 BOOST_TEST( testerv( bind(fv_1, _1), i ) == 1L );
170 BOOST_TEST( testerv( bind(fv_2, _1, 2), i ) == 21L );
171 BOOST_TEST( testerv( bind(fv_3, _1, 2, 3), i ) == 321L );
172 BOOST_TEST( testerv( bind(fv_4, _1, 2, 3, 4), i ) == 4321L );
173 BOOST_TEST( testerv( bind(fv_5, _1, 2, 3, 4, 5), i ) == 54321L );
174 BOOST_TEST( testerv( bind(fv_6, _1, 2, 3, 4, 5, 6), i ) == 654321L );
175 BOOST_TEST( testerv( bind(fv_7, _1, 2, 3, 4, 5, 6, 7), i ) == 7654321L );
176 BOOST_TEST( testerv( bind(fv_8, _1, 2, 3, 4, 5, 6, 7, 8), i ) == 87654321L );
177 BOOST_TEST( testerv( bind(fv_9, _1, 2, 3, 4, 5, 6, 7, 8, 9), i ) == 987654321L );
178 }
179
180 int main()
181 {
182 function_test();
183 return boost::report_errors();
184 }