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