]>
git.proxmox.com Git - ceph.git/blob - 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
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 ==============================================================================*/
11 #include <boost/config.hpp>
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
20 #include <boost/phoenix/core.hpp>
21 #include <boost/phoenix/bind.hpp>
23 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
24 #pragma warning(push, 3)
29 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
33 #include <boost/detail/lightweight_test.hpp>
47 long f_2(long a
, long b
)
52 long f_3(long a
, long b
, long c
)
54 return a
+ 10 * b
+ 100 * c
;
57 long f_4(long a
, long b
, long c
, long d
)
59 return a
+ 10 * b
+ 100 * c
+ 1000 * d
;
62 long f_5(long a
, long b
, long c
, long d
, long e
)
64 return a
+ 10 * b
+ 100 * c
+ 1000 * d
+ 10000 * e
;
67 long f_6(long a
, long b
, long c
, long d
, long e
, long f
)
69 return a
+ 10 * b
+ 100 * c
+ 1000 * d
+ 10000 * e
+ 100000 * f
;
72 long f_7(long a
, long b
, long c
, long d
, long e
, long f
, long g
)
74 return a
+ 10 * b
+ 100 * c
+ 1000 * d
+ 10000 * e
+ 100000 * f
+ 1000000 * g
;
77 long f_8(long a
, long b
, long c
, long d
, long e
, long f
, long g
, long h
)
79 return a
+ 10 * b
+ 100 * c
+ 1000 * d
+ 10000 * e
+ 100000 * f
+ 1000000 * g
+ 10000000 * h
;
82 long f_9(long a
, long b
, long c
, long d
, long e
, long f
, long g
, long h
, long i
)
84 return a
+ 10 * b
+ 100 * c
+ 1000 * d
+ 10000 * e
+ 100000 * f
+ 1000000 * g
+ 10000000 * h
+ 100000000 * i
;
91 global_result
= 17041L;
99 void fv_2(long a
, long b
)
101 global_result
= a
+ 10 * b
;
104 void fv_3(long a
, long b
, long c
)
106 global_result
= a
+ 10 * b
+ 100 * c
;
109 void fv_4(long a
, long b
, long c
, long d
)
111 global_result
= a
+ 10 * b
+ 100 * c
+ 1000 * d
;
114 void fv_5(long a
, long b
, long c
, long d
, long e
)
116 global_result
= a
+ 10 * b
+ 100 * c
+ 1000 * d
+ 10000 * e
;
119 void fv_6(long a
, long b
, long c
, long d
, long e
, long f
)
121 global_result
= a
+ 10 * b
+ 100 * c
+ 1000 * d
+ 10000 * e
+ 100000 * f
;
124 void fv_7(long a
, long b
, long c
, long d
, long e
, long f
, long g
)
126 global_result
= a
+ 10 * b
+ 100 * c
+ 1000 * d
+ 10000 * e
+ 100000 * f
+ 1000000 * g
;
129 void fv_8(long a
, long b
, long c
, long d
, long e
, long f
, long g
, long h
)
131 global_result
= a
+ 10 * b
+ 100 * c
+ 1000 * d
+ 10000 * e
+ 100000 * f
+ 1000000 * g
+ 10000000 * h
;
134 void fv_9(long a
, long b
, long c
, long d
, long e
, long f
, long g
, long h
, long i
)
136 global_result
= a
+ 10 * b
+ 100 * c
+ 1000 * d
+ 10000 * e
+ 100000 * f
+ 1000000 * g
+ 10000000 * h
+ 100000000 * i
;
139 template<class F
, class A
> long tester(F
const & f
, A
const & a
)
144 template<class F
, class A
> long testerv(F
const & f
, A
const & a
)
147 return global_result
;
152 using boost::phoenix::bind
;
153 using boost::phoenix::placeholders::_1
;
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 );
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 );
183 return boost::report_errors();