]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/bind/test/bind_eq_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_eq_test.cpp - boost::bind equality operator
13 // Copyright (c) 2004, 2005 Peter Dimov
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)
20 #include <boost/bind.hpp>
21 #include <boost/ref.hpp>
23 #ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
24 # include <boost/function_equal.hpp>
27 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
28 #pragma warning(push, 3)
33 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
37 #include <boost/detail/lightweight_test.hpp>
43 explicit X(int i
): i_(i
)
47 bool operator==(X
const & rhs
) const
80 int f_5(X
, X
, X
, X
, X
)
85 int f_6(X
, X
, X
, X
, X
, X
)
90 int f_7(X
, X
, X
, X
, X
, X
, X
)
95 int f_8(X
, X
, X
, X
, X
, X
, X
, X
)
100 int f_9(X
, X
, X
, X
, X
, X
, X
, X
, X
)
123 void fv_4(X
, X
, X
, X
)
127 void fv_5(X
, X
, X
, X
, X
)
131 void fv_6(X
, X
, X
, X
, X
, X
)
135 void fv_7(X
, X
, X
, X
, X
, X
, X
)
139 void fv_8(X
, X
, X
, X
, X
, X
, X
, X
)
143 void fv_9(X
, X
, X
, X
, X
, X
, X
, X
, X
)
147 template<class F
> void test_eq(F f1
, F f2
)
149 #ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
151 using boost::function_equal
;
155 BOOST_TEST( function_equal( f1
, f2
) );
158 template<class F
> void test_ne(F f1
, F f2
)
160 #ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
162 using boost::function_equal
;
166 BOOST_TEST( !function_equal( f1
, f2
) );
171 template<class F
> void test_0(F f
)
173 test_eq( boost::bind(f
), boost::bind(f
) );
178 template<class F
, class V
> void test_1_(F f
, V v1
, V v2
)
180 test_eq( boost::bind(f
, v1
), boost::bind(f
, v1
) );
181 test_ne( boost::bind(f
, v1
), boost::bind(f
, v2
) );
184 template<class F
> void test_1(F f
)
186 test_eq( boost::bind(f
, _1
), boost::bind(f
, _1
) );
188 test_1_( f
, X(1), X(2) );
191 test_1_( f
, boost::ref(a
), boost::ref(b
) );
196 template<class F
, class V
> void test_2_(F f
, V v1
, V v2
)
198 test_eq( boost::bind(f
, v1
, v1
), boost::bind(f
, v1
, v1
) );
199 test_ne( boost::bind(f
, v1
, v1
), boost::bind(f
, v1
, v2
) );
200 test_ne( boost::bind(f
, v1
, v1
), boost::bind(f
, v2
, v1
) );
203 template<class F
> void test_2(F f
)
205 test_eq( boost::bind(f
, _1
, _2
), boost::bind(f
, _1
, _2
) );
207 test_2_( f
, X(1), X(2) );
210 test_2_( f
, boost::ref(a
), boost::ref(b
) );
215 template<class F
, class V
> void test_3_(F f
, V v1
, V v2
)
217 test_eq( boost::bind(f
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
) );
218 test_ne( boost::bind(f
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v2
) );
219 test_ne( boost::bind(f
, v1
, v1
, v1
), boost::bind(f
, v1
, v2
, v1
) );
220 test_ne( boost::bind(f
, v1
, v1
, v1
), boost::bind(f
, v2
, v1
, v1
) );
223 template<class F
> void test_3(F f
)
225 test_eq( boost::bind(f
, _1
, _2
, _3
), boost::bind(f
, _1
, _2
, _3
) );
227 test_3_( f
, X(1), X(2) );
230 test_3_( f
, boost::ref(a
), boost::ref(b
) );
235 template<class F
, class V
> void test_4_(F f
, V v1
, V v2
)
237 test_eq( boost::bind(f
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
) );
238 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v2
) );
239 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v2
, v1
) );
240 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v2
, v1
, v1
) );
241 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
), boost::bind(f
, v2
, v1
, v1
, v1
) );
244 template<class F
> void test_4(F f
)
246 test_eq( boost::bind(f
, _1
, _2
, _3
, _4
), boost::bind(f
, _1
, _2
, _3
, _4
) );
248 test_4_( f
, X(1), X(2) );
251 test_4_( f
, boost::ref(a
), boost::ref(b
) );
256 template<class F
, class V
> void test_5_(F f
, V v1
, V v2
)
258 test_eq( boost::bind(f
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v1
) );
259 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v2
) );
260 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v2
, v1
) );
261 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v2
, v1
, v1
) );
262 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v2
, v1
, v1
, v1
) );
263 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v2
, v1
, v1
, v1
, v1
) );
266 template<class F
> void test_5(F f
)
268 test_eq( boost::bind(f
, _1
, _2
, _3
, _4
, _5
), boost::bind(f
, _1
, _2
, _3
, _4
, _5
) );
270 test_5_( f
, X(1), X(2) );
273 test_5_( f
, boost::ref(a
), boost::ref(b
) );
278 template<class F
, class V
> void test_6_(F f
, V v1
, V v2
)
280 test_eq( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
) );
281 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v2
) );
282 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v2
, v1
) );
283 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v2
, v1
, v1
) );
284 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v2
, v1
, v1
, v1
) );
285 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v2
, v1
, v1
, v1
, v1
) );
286 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v2
, v1
, v1
, v1
, v1
, v1
) );
289 template<class F
> void test_6(F f
)
291 test_eq( boost::bind(f
, _1
, _2
, _3
, _4
, _5
, _6
), boost::bind(f
, _1
, _2
, _3
, _4
, _5
, _6
) );
293 test_6_( f
, X(1), X(2) );
296 test_6_( f
, boost::ref(a
), boost::ref(b
) );
301 template<class F
, class V
> void test_7_(F f
, V v1
, V v2
)
303 test_eq( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
) );
304 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v2
) );
305 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v2
, v1
) );
306 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v2
, v1
, v1
) );
307 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v2
, v1
, v1
, v1
) );
308 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v2
, v1
, v1
, v1
, v1
) );
309 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v2
, v1
, v1
, v1
, v1
, v1
) );
310 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v2
, v1
, v1
, v1
, v1
, v1
, v1
) );
313 template<class F
> void test_7(F f
)
315 test_eq( boost::bind(f
, _1
, _2
, _3
, _4
, _5
, _6
, _7
), boost::bind(f
, _1
, _2
, _3
, _4
, _5
, _6
, _7
) );
317 test_7_( f
, X(1), X(2) );
320 test_7_( f
, boost::ref(a
), boost::ref(b
) );
325 template<class F
, class V
> void test_8_(F f
, V v1
, V v2
)
327 test_eq( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
) );
328 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v2
) );
329 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v2
, v1
) );
330 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v2
, v1
, v1
) );
331 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v2
, v1
, v1
, v1
) );
332 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v2
, v1
, v1
, v1
, v1
) );
333 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v2
, v1
, v1
, v1
, v1
, v1
) );
334 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v2
, v1
, v1
, v1
, v1
, v1
, v1
) );
335 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v2
, v1
, v1
, v1
, v1
, v1
, v1
, v1
) );
338 template<class F
> void test_8(F f
)
340 test_eq( boost::bind(f
, _1
, _2
, _3
, _4
, _5
, _6
, _7
, _8
), boost::bind(f
, _1
, _2
, _3
, _4
, _5
, _6
, _7
, _8
) );
342 test_8_( f
, X(1), X(2) );
345 test_8_( f
, boost::ref(a
), boost::ref(b
) );
350 template<class F
, class V
> void test_9_(F f
, V v1
, V v2
)
352 test_eq( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
) );
353 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v2
) );
354 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v2
, v1
) );
355 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v2
, v1
, v1
) );
356 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v2
, v1
, v1
, v1
) );
357 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v1
, v2
, v1
, v1
, v1
, v1
) );
358 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v1
, v2
, v1
, v1
, v1
, v1
, v1
) );
359 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v1
, v2
, v1
, v1
, v1
, v1
, v1
, v1
) );
360 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v1
, v2
, v1
, v1
, v1
, v1
, v1
, v1
, v1
) );
361 test_ne( boost::bind(f
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
), boost::bind(f
, v2
, v1
, v1
, v1
, v1
, v1
, v1
, v1
, v1
) );
364 template<class F
> void test_9(F f
)
366 test_eq( boost::bind(f
, _1
, _2
, _3
, _4
, _5
, _6
, _7
, _8
, _9
), boost::bind(f
, _1
, _2
, _3
, _4
, _5
, _6
, _7
, _8
, _9
) );
368 test_9_( f
, X(1), X(2) );
371 test_9_( f
, boost::ref(a
), boost::ref(b
) );
426 return boost::report_errors();