]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/bind/test/bind_function2_test.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / bind / test / bind_function2_test.cpp
CommitLineData
7c673cae 1#include <boost/config.hpp>
1e59de90
TL
2#include <boost/config/pragma_message.hpp>
3
4#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ( defined(BOOST_GCC) && BOOST_GCC < 40600 )
5
6BOOST_PRAGMA_MESSAGE( "Skipping test for GCC 4.4 -std=c++0x" )
7int main() {}
8
9#else
7c673cae
FG
10
11//
12// bind_function2_test.cpp - regression test
13//
14// Copyright (c) 2015 Peter Dimov
15//
16// Distributed under the Boost Software License, Version 1.0.
17// See accompanying file LICENSE_1_0.txt or copy at
18// http://www.boost.org/LICENSE_1_0.txt
19//
20
f67539c2 21#include <boost/bind/bind.hpp>
7c673cae 22#include <boost/function.hpp>
f67539c2
TL
23#include <boost/core/lightweight_test.hpp>
24
25using namespace boost::placeholders;
7c673cae
FG
26
27//
28
29void fv1( int & a )
30{
31 a = 17041;
32}
33
34void fv2( int & a, int b )
35{
36 a = b;
37}
38
39void fv3( int & a, int b, int c )
40{
41 a = b + c;
42}
43
44void fv4( int & a, int b, int c, int d )
45{
46 a = b + c + d;
47}
48
49void fv5( int & a, int b, int c, int d, int e )
50{
51 a = b + c + d + e;
52}
53
54void fv6( int & a, int b, int c, int d, int e, int f )
55{
56 a = b + c + d + e + f;
57}
58
59void fv7( int & a, int b, int c, int d, int e, int f, int g )
60{
61 a = b + c + d + e + f + g;
62}
63
64void fv8( int & a, int b, int c, int d, int e, int f, int g, int h )
65{
66 a = b + c + d + e + f + g + h;
67}
68
69void fv9( int & a, int b, int c, int d, int e, int f, int g, int h, int i )
70{
71 a = b + c + d + e + f + g + h + i;
72}
73
74void function_test()
75{
76 int x = 0;
77
78 {
79 boost::function<void(int&)> fw1 = boost::bind( fv1, _1 );
80 fw1( x ); BOOST_TEST( x == 17041 );
81 }
82
83 {
84 boost::function<void(int&, int)> fw2 = boost::bind( fv2, _1, _2 );
85 fw2( x, 1 ); BOOST_TEST( x == 1 );
86 }
87
88 {
89 boost::function<void(int&, int, int)> fw3 = boost::bind( fv3, _1, _2, _3 );
90 fw3( x, 1, 2 ); BOOST_TEST( x == 1+2 );
91 }
92
93 {
94 boost::function<void(int&, int, int, int)> fw4 = boost::bind( fv4, _1, _2, _3, _4 );
95 fw4( x, 1, 2, 3 ); BOOST_TEST( x == 1+2+3 );
96 }
97
98 {
99 boost::function<void(int&, int, int, int, int)> fw5 = boost::bind( fv5, _1, _2, _3, _4, _5 );
100 fw5( x, 1, 2, 3, 4 ); BOOST_TEST( x == 1+2+3+4 );
101 }
102
103 {
104 boost::function<void(int&, int, int, int, int, int)> fw6 = boost::bind( fv6, _1, _2, _3, _4, _5, _6 );
105 fw6( x, 1, 2, 3, 4, 5 ); BOOST_TEST( x == 1+2+3+4+5 );
106 }
107
108 {
109 boost::function<void(int&, int, int, int, int, int, int)> fw7 = boost::bind( fv7, _1, _2, _3, _4, _5, _6, _7 );
110 fw7( x, 1, 2, 3, 4, 5, 6 ); BOOST_TEST( x == 1+2+3+4+5+6 );
111 }
112
113 {
114 boost::function<void(int&, int, int, int, int, int, int, int)> fw8 = boost::bind( fv8, _1, _2, _3, _4, _5, _6, _7, _8 );
115 fw8( x, 1, 2, 3, 4, 5, 6, 7 ); BOOST_TEST( x == 1+2+3+4+5+6+7 );
116 }
117
118 {
119 boost::function<void(int&, int, int, int, int, int, int, int, int)> fw9 = boost::bind( fv9, _1, _2, _3, _4, _5, _6, _7, _8, _9 );
120 fw9( x, 1, 2, 3, 4, 5, 6, 7, 8 ); BOOST_TEST( x == 1+2+3+4+5+6+7+8 );
121 }
122}
123
124int main()
125{
126 function_test();
127 return boost::report_errors();
128}
1e59de90
TL
129
130#endif