]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/bind/test/bind_function_ap_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / bind / test / bind_function_ap_test.cpp
1 #include <boost/config.hpp>
2
3 //
4 // bind_function_ap_test.cpp - regression test
5 //
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 #if defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 406 )
14 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
15 #elif defined( __clang__ ) && defined( __has_warning )
16 # if __has_warning( "-Wdeprecated-declarations" )
17 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
18 # endif
19 #endif
20
21 #include <boost/bind.hpp>
22 #include <boost/function.hpp>
23 #include <boost/detail/lightweight_test.hpp>
24 #include <memory>
25
26 //
27
28 void fv1( std::auto_ptr<int> p1 )
29 {
30 BOOST_TEST( *p1 == 1 );
31 }
32
33 void fv2( std::auto_ptr<int> p1, std::auto_ptr<int> p2 )
34 {
35 BOOST_TEST( *p1 == 1 );
36 BOOST_TEST( *p2 == 2 );
37 }
38
39 void fv3( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3 )
40 {
41 BOOST_TEST( *p1 == 1 );
42 BOOST_TEST( *p2 == 2 );
43 BOOST_TEST( *p3 == 3 );
44 }
45
46 void fv4( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4 )
47 {
48 BOOST_TEST( *p1 == 1 );
49 BOOST_TEST( *p2 == 2 );
50 BOOST_TEST( *p3 == 3 );
51 BOOST_TEST( *p4 == 4 );
52 }
53
54 void fv5( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4, std::auto_ptr<int> p5 )
55 {
56 BOOST_TEST( *p1 == 1 );
57 BOOST_TEST( *p2 == 2 );
58 BOOST_TEST( *p3 == 3 );
59 BOOST_TEST( *p4 == 4 );
60 BOOST_TEST( *p5 == 5 );
61 }
62
63 void fv6( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4, std::auto_ptr<int> p5, std::auto_ptr<int> p6 )
64 {
65 BOOST_TEST( *p1 == 1 );
66 BOOST_TEST( *p2 == 2 );
67 BOOST_TEST( *p3 == 3 );
68 BOOST_TEST( *p4 == 4 );
69 BOOST_TEST( *p5 == 5 );
70 BOOST_TEST( *p6 == 6 );
71 }
72
73 void fv7( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4, std::auto_ptr<int> p5, std::auto_ptr<int> p6, std::auto_ptr<int> p7 )
74 {
75 BOOST_TEST( *p1 == 1 );
76 BOOST_TEST( *p2 == 2 );
77 BOOST_TEST( *p3 == 3 );
78 BOOST_TEST( *p4 == 4 );
79 BOOST_TEST( *p5 == 5 );
80 BOOST_TEST( *p6 == 6 );
81 BOOST_TEST( *p7 == 7 );
82 }
83
84 void fv8( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4, std::auto_ptr<int> p5, std::auto_ptr<int> p6, std::auto_ptr<int> p7, std::auto_ptr<int> p8 )
85 {
86 BOOST_TEST( *p1 == 1 );
87 BOOST_TEST( *p2 == 2 );
88 BOOST_TEST( *p3 == 3 );
89 BOOST_TEST( *p4 == 4 );
90 BOOST_TEST( *p5 == 5 );
91 BOOST_TEST( *p6 == 6 );
92 BOOST_TEST( *p7 == 7 );
93 BOOST_TEST( *p8 == 8 );
94 }
95
96 void fv9( std::auto_ptr<int> p1, std::auto_ptr<int> p2, std::auto_ptr<int> p3, std::auto_ptr<int> p4, std::auto_ptr<int> p5, std::auto_ptr<int> p6, std::auto_ptr<int> p7, std::auto_ptr<int> p8, std::auto_ptr<int> p9 )
97 {
98 BOOST_TEST( *p1 == 1 );
99 BOOST_TEST( *p2 == 2 );
100 BOOST_TEST( *p3 == 3 );
101 BOOST_TEST( *p4 == 4 );
102 BOOST_TEST( *p5 == 5 );
103 BOOST_TEST( *p6 == 6 );
104 BOOST_TEST( *p7 == 7 );
105 BOOST_TEST( *p8 == 8 );
106 BOOST_TEST( *p9 == 9 );
107 }
108
109 void test()
110 {
111 {
112 boost::function<void(std::auto_ptr<int>)> fw1 = boost::bind( fv1, _1 );
113
114 std::auto_ptr<int> p1( new int(1) );
115
116 fw1( p1 );
117 }
118
119 {
120 boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>)> fw2 = boost::bind( fv2, _1, _2 );
121
122 std::auto_ptr<int> p1( new int(1) );
123 std::auto_ptr<int> p2( new int(2) );
124
125 fw2( p1, p2 );
126 }
127
128 {
129 boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw3 = boost::bind( fv3, _1, _2, _3 );
130
131 std::auto_ptr<int> p1( new int(1) );
132 std::auto_ptr<int> p2( new int(2) );
133 std::auto_ptr<int> p3( new int(3) );
134
135 fw3( p1, p2, p3 );
136 }
137
138 {
139 boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw4 = boost::bind( fv4, _1, _2, _3, _4 );
140
141 std::auto_ptr<int> p1( new int(1) );
142 std::auto_ptr<int> p2( new int(2) );
143 std::auto_ptr<int> p3( new int(3) );
144 std::auto_ptr<int> p4( new int(4) );
145
146 fw4( p1, p2, p3, p4 );
147 }
148
149 {
150 boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw5 = boost::bind( fv5, _1, _2, _3, _4, _5 );
151
152 std::auto_ptr<int> p1( new int(1) );
153 std::auto_ptr<int> p2( new int(2) );
154 std::auto_ptr<int> p3( new int(3) );
155 std::auto_ptr<int> p4( new int(4) );
156 std::auto_ptr<int> p5( new int(5) );
157
158 fw5( p1, p2, p3, p4, p5 );
159 }
160
161 {
162 boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw6 = boost::bind( fv6, _1, _2, _3, _4, _5, _6 );
163
164 std::auto_ptr<int> p1( new int(1) );
165 std::auto_ptr<int> p2( new int(2) );
166 std::auto_ptr<int> p3( new int(3) );
167 std::auto_ptr<int> p4( new int(4) );
168 std::auto_ptr<int> p5( new int(5) );
169 std::auto_ptr<int> p6( new int(6) );
170
171 fw6( p1, p2, p3, p4, p5, p6 );
172 }
173
174 {
175 boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw7 = boost::bind( fv7, _1, _2, _3, _4, _5, _6, _7 );
176
177 std::auto_ptr<int> p1( new int(1) );
178 std::auto_ptr<int> p2( new int(2) );
179 std::auto_ptr<int> p3( new int(3) );
180 std::auto_ptr<int> p4( new int(4) );
181 std::auto_ptr<int> p5( new int(5) );
182 std::auto_ptr<int> p6( new int(6) );
183 std::auto_ptr<int> p7( new int(7) );
184
185 fw7( p1, p2, p3, p4, p5, p6, p7 );
186 }
187
188 {
189 boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw8 = boost::bind( fv8, _1, _2, _3, _4, _5, _6, _7, _8 );
190
191 std::auto_ptr<int> p1( new int(1) );
192 std::auto_ptr<int> p2( new int(2) );
193 std::auto_ptr<int> p3( new int(3) );
194 std::auto_ptr<int> p4( new int(4) );
195 std::auto_ptr<int> p5( new int(5) );
196 std::auto_ptr<int> p6( new int(6) );
197 std::auto_ptr<int> p7( new int(7) );
198 std::auto_ptr<int> p8( new int(8) );
199
200 fw8( p1, p2, p3, p4, p5, p6, p7, p8 );
201 }
202
203 {
204 boost::function<void(std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>, std::auto_ptr<int>)> fw9 = boost::bind( fv9, _1, _2, _3, _4, _5, _6, _7, _8, _9 );
205
206 std::auto_ptr<int> p1( new int(1) );
207 std::auto_ptr<int> p2( new int(2) );
208 std::auto_ptr<int> p3( new int(3) );
209 std::auto_ptr<int> p4( new int(4) );
210 std::auto_ptr<int> p5( new int(5) );
211 std::auto_ptr<int> p6( new int(6) );
212 std::auto_ptr<int> p7( new int(7) );
213 std::auto_ptr<int> p8( new int(8) );
214 std::auto_ptr<int> p9( new int(9) );
215
216 fw9( p1, p2, p3, p4, p5, p6, p7, p8, p9 );
217 }
218 }
219
220 int main()
221 {
222 test();
223 return boost::report_errors();
224 }