1 //
2 // bind_no_placeholders_test.cpp - test for BOOST_BIND_NO_PLACEHOLDERS
3 //
4 // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
5 // Copyright (c) 2001 David Abrahams
6 // Copyright (c) 2015 Peter Dimov
7 //
8 // Distributed under the Boost Software License, Version 1.0.
9 // See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt
11 //
12
13 #define BOOST_BIND_NO_PLACEHOLDERS
14 #include <boost/bind.hpp>
15 #include <boost/core/lightweight_test.hpp>
16
17 //
18
f_0()19 long f_0()
20 {
21 return 17041L;
22 }
23
f_1(long a)24 long f_1(long a)
25 {
26 return a;
27 }
28
f_2(long a,long b)29 long f_2(long a, long b)
30 {
31 return a + 10 * b;
32 }
33
f_3(long a,long b,long c)34 long f_3(long a, long b, long c)
35 {
36 return a + 10 * b + 100 * c;
37 }
38
f_4(long a,long b,long c,long d)39 long f_4(long a, long b, long c, long d)
40 {
41 return a + 10 * b + 100 * c + 1000 * d;
42 }
43
f_5(long a,long b,long c,long d,long e)44 long f_5(long a, long b, long c, long d, long e)
45 {
46 return a + 10 * b + 100 * c + 1000 * d + 10000 * e;
47 }
48
f_6(long a,long b,long c,long d,long e,long f)49 long f_6(long a, long b, long c, long d, long e, long f)
50 {
51 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
52 }
53
f_7(long a,long b,long c,long d,long e,long f,long g)54 long f_7(long a, long b, long c, long d, long e, long f, long g)
55 {
56 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
57 }
58
f_8(long a,long b,long c,long d,long e,long f,long g,long h)59 long f_8(long a, long b, long c, long d, long e, long f, long g, long h)
60 {
61 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
62 }
63
f_9(long a,long b,long c,long d,long e,long f,long g,long h,long i)64 long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
65 {
66 return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
67 }
68
function_test()69 void function_test()
70 {
71 using namespace boost;
72
73 arg<1> _1;
74 arg<2> _2;
75 arg<3> _3;
76 arg<4> _4;
77 arg<5> _5;
78 arg<6> _6;
79 arg<7> _7;
80 arg<8> _8;
81 arg<9> _9;
82
83 BOOST_TEST( bind(f_0)() == 17041L );
84 BOOST_TEST( bind(f_1, _1)(1) == 1L );
85 BOOST_TEST( bind(f_2, _1, _2)(1, 2) == 21L );
86 BOOST_TEST( bind(f_3, _1, _2, _3)(1, 2, 3) == 321L );
87 BOOST_TEST( bind(f_4, _1, _2, _3, _4)(1, 2, 3, 4) == 4321L );
88 BOOST_TEST( bind(f_5, _1, _2, _3, _4, _5)(1, 2, 3, 4, 5) == 54321L );
89 BOOST_TEST( bind(f_6, _1, _2, _3, _4, _5, _6)(1, 2, 3, 4, 5, 6) == 654321L );
90 BOOST_TEST( bind(f_7, _1, _2, _3, _4, _5, _6, _7)(1, 2, 3, 4, 5, 6, 7) == 7654321L );
91 BOOST_TEST( bind(f_8, _1, _2, _3, _4, _5, _6, _7, _8)(1, 2, 3, 4, 5, 6, 7, 8) == 87654321L );
92 BOOST_TEST( bind(f_9, _1, _2, _3, _4, _5, _6, _7, _8, _9)(1, 2, 3, 4, 5, 6, 7, 8, 9) == 987654321L );
93 }
94
main()95 int main()
96 {
97 function_test();
98 return boost::report_errors();
99 }
100