1// Copyright David Abrahams 2005.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5
6#include <boost/parameter/aux_/unwrap_cv_reference.hpp>
7#include <boost/parameter/config.hpp>
8#include <boost/mpl/aux_/test.hpp>
9
10#if defined(BOOST_PARAMETER_CAN_USE_MP11)
11#include <type_traits>
12#else
13#include <boost/mpl/bool.hpp>
14#include <boost/mpl/if.hpp>
15#include <boost/mpl/assert.hpp>
16#include <boost/type_traits/is_same.hpp>
17#endif
18
19MPL_TEST_CASE()
20{
21#if defined(BOOST_PARAMETER_CAN_USE_MP11)
22 static_assert(
23 std::is_same<
24 boost::parameter::aux::unwrap_cv_reference<int>::type
25 , int
26 >::value
27 , "unwrap_cv_reference<int>::type == int"
28 );
29 static_assert(
30 std::is_same<
31 boost::parameter::aux::unwrap_cv_reference<int const>::type
32 , int const
33 >::value
34 , "unwrap_cv_reference<int const>::type == int const"
35 );
36 static_assert(
37 std::is_same<
38 boost::parameter::aux::unwrap_cv_reference<int volatile>::type
39 , int volatile
40 >::value
41 , "unwrap_cv_reference<int volatile>::type == int volatile"
42 );
43 static_assert(
44 std::is_same<
45 boost::parameter::aux::unwrap_cv_reference<
46 int const volatile
47 >::type
48 , int const volatile
49 >::value
50 , "unwrap_cv_reference<int cv>::type == int cv"
51 );
52#else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
53 BOOST_MPL_ASSERT((
54 boost::mpl::if_<
55 boost::is_same<
56 boost::parameter::aux::unwrap_cv_reference<int>::type
57 , int
58 >
59 , boost::mpl::true_
60 , boost::mpl::false_
61 >::type
62 ));
63 BOOST_MPL_ASSERT((
64 boost::mpl::if_<
65 boost::is_same<
66 boost::parameter::aux::unwrap_cv_reference<int const>::type
67 , int const
68 >
69 , boost::mpl::true_
70 , boost::mpl::false_
71 >::type
72 ));
73 BOOST_MPL_ASSERT((
74 boost::mpl::if_<
75 boost::is_same<
76 boost::parameter::aux::unwrap_cv_reference<int volatile>::type
77 , int volatile
78 >
79 , boost::mpl::true_
80 , boost::mpl::false_
81 >::type
82 ));
83 BOOST_MPL_ASSERT((
84 boost::mpl::if_<
85 boost::is_same<
86 boost::parameter::aux::unwrap_cv_reference<
87 int const volatile
88 >::type
89 , int const volatile
90 >
91 , boost::mpl::true_
92 , boost::mpl::false_
93 >::type
94 ));
95#endif // BOOST_PARAMETER_CAN_USE_MP11
96}
97
98namespace test {
99
100 struct foo
101 {
102 };
103} // namespace test
104
105MPL_TEST_CASE()
106{
107#if defined(BOOST_PARAMETER_CAN_USE_MP11)
108 static_assert(
109 std::is_same<
110 boost::parameter::aux::unwrap_cv_reference<test::foo>::type
111 , test::foo
112 >::value
113 , "unwrap_cv_reference<test::foo>::type == test::foo"
114 );
115 static_assert(
116 std::is_same<
117 boost::parameter::aux::unwrap_cv_reference<test::foo const>::type
118 , test::foo const
119 >::value
120 , "unwrap_cv_reference<test::foo const>::type == test::foo const"
121 );
122 static_assert(
123 std::is_same<
124 boost::parameter::aux::unwrap_cv_reference<
125 test::foo volatile
126 >::type
127 , test::foo volatile
128 >::value
129 , "unwrap_cv_reference<test::foo volatile>::type == test::foo volatile"
130 );
131 static_assert(
132 std::is_same<
133 boost::parameter::aux::unwrap_cv_reference<
134 test::foo const volatile
135 >::type
136 , test::foo const volatile
137 >::value
138 , "unwrap_cv_reference<test::foo cv>::type == test::foo cv"
139 );
140#else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
141 BOOST_MPL_ASSERT((
142 boost::mpl::if_<
143 boost::is_same<
144 boost::parameter::aux::unwrap_cv_reference<test::foo>::type
145 , test::foo
146 >
147 , boost::mpl::true_
148 , boost::mpl::false_
149 >::type
150 ));
151 BOOST_MPL_ASSERT((
152 boost::mpl::if_<
153 boost::is_same<
154 boost::parameter::aux::unwrap_cv_reference<
155 test::foo const
156 >::type
157 , test::foo const
158 >
159 , boost::mpl::true_
160 , boost::mpl::false_
161 >::type
162 ));
163 BOOST_MPL_ASSERT((
164 boost::mpl::if_<
165 boost::is_same<
166 boost::parameter::aux::unwrap_cv_reference<
167 test::foo volatile
168 >::type
169 , test::foo volatile
170 >
171 , boost::mpl::true_
172 , boost::mpl::false_
173 >::type
174 ));
175 BOOST_MPL_ASSERT((
176 boost::mpl::if_<
177 boost::is_same<
178 boost::parameter::aux::unwrap_cv_reference<
179 test::foo const volatile
180 >::type
181 , test::foo const volatile
182 >
183 , boost::mpl::true_
184 , boost::mpl::false_
185 >::type
186 ));
187#endif // BOOST_PARAMETER_CAN_USE_MP11
188}
189
190#include <boost/ref.hpp>
191
192MPL_TEST_CASE()
193{
194#if defined(BOOST_PARAMETER_CAN_USE_MP11)
195 static_assert(
196 std::is_same<
197 boost::parameter::aux::unwrap_cv_reference<
198 boost::reference_wrapper<test::foo>
199 >::type
200 , test::foo
201 >::value
202 , "unwrap_cv_reference<ref(test::foo)>::type == test::foo"
203 );
204 static_assert(
205 std::is_same<
206 boost::parameter::aux::unwrap_cv_reference<
207 boost::reference_wrapper<test::foo> const
208 >::type
209 , test::foo
210 >::value
211 , "unwrap_cv_reference<ref(test::foo) const>::type == test::foo"
212 );
213 static_assert(
214 std::is_same<
215 boost::parameter::aux::unwrap_cv_reference<
216 boost::reference_wrapper<test::foo> volatile
217 >::type
218 , test::foo
219 >::value
220 , "unwrap_cv_reference<ref(test::foo) volatile>::type == test::foo"
221 );
222 static_assert(
223 std::is_same<
224 boost::parameter::aux::unwrap_cv_reference<
225 boost::reference_wrapper<test::foo> const volatile
226 >::type
227 , test::foo
228 >::value
229 , "unwrap_cv_reference<ref(test::foo) cv>::type == test::foo"
230 );
231#else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
232 BOOST_MPL_ASSERT((
233 boost::mpl::if_<
234 boost::is_same<
235 boost::parameter::aux::unwrap_cv_reference<
236 boost::reference_wrapper<test::foo>
237 >::type
238 , test::foo
239 >
240 , boost::mpl::true_
241 , boost::mpl::false_
242 >::type
243 ));
244 BOOST_MPL_ASSERT((
245 boost::mpl::if_<
246 boost::is_same<
247 boost::parameter::aux::unwrap_cv_reference<
248 boost::reference_wrapper<test::foo> const
249 >::type
250 , test::foo
251 >
252 , boost::mpl::true_
253 , boost::mpl::false_
254 >::type
255 ));
256 BOOST_MPL_ASSERT((
257 boost::mpl::if_<
258 boost::is_same<
259 boost::parameter::aux::unwrap_cv_reference<
260 boost::reference_wrapper<test::foo> volatile
261 >::type
262 , test::foo
263 >
264 , boost::mpl::true_
265 , boost::mpl::false_
266 >::type
267 ));
268 BOOST_MPL_ASSERT((
269 boost::mpl::if_<
270 boost::is_same<
271 boost::parameter::aux::unwrap_cv_reference<
272 boost::reference_wrapper<test::foo> const volatile
273 >::type
274 , test::foo
275 >
276 , boost::mpl::true_
277 , boost::mpl::false_
278 >::type
279 ));
280#endif // BOOST_PARAMETER_CAN_USE_MP11
281}
282
283#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
284#include <functional>
285
286MPL_TEST_CASE()
287{
288#if defined(BOOST_PARAMETER_CAN_USE_MP11)
289 static_assert(
290 std::is_same<
291 boost::parameter::aux::unwrap_cv_reference<
292 std::reference_wrapper<test::foo>
293 >::type
294 , test::foo
295 >::value
296 , "unwrap_cv_reference<std::ref(test::foo)>::type == test::foo"
297 );
298 static_assert(
299 std::is_same<
300 boost::parameter::aux::unwrap_cv_reference<
301 std::reference_wrapper<test::foo> const
302 >::type
303 , test::foo
304 >::value
305 , "unwrap_cv_reference<std::ref(test::foo) const>::type == test::foo"
306 );
307 static_assert(
308 std::is_same<
309 boost::parameter::aux::unwrap_cv_reference<
310 std::reference_wrapper<test::foo> volatile
311 >::type
312 , test::foo
313 >::value
314 , "unwrap_cv_reference<std::ref(test::foo) volatile>::type == test::foo"
315 );
316 static_assert(
317 std::is_same<
318 boost::parameter::aux::unwrap_cv_reference<
319 std::reference_wrapper<test::foo> const volatile
320 >::type
321 , test::foo
322 >::value
323 , "unwrap_cv_reference<std::ref(test::foo) cv>::type == test::foo"
324 );
325#else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
326 BOOST_MPL_ASSERT((
327 boost::mpl::if_<
328 boost::is_same<
329 boost::parameter::aux::unwrap_cv_reference<
330 std::reference_wrapper<test::foo>
331 >::type
332 , test::foo
333 >
334 , boost::mpl::true_
335 , boost::mpl::false_
336 >::type
337 ));
338 BOOST_MPL_ASSERT((
339 boost::mpl::if_<
340 boost::is_same<
341 boost::parameter::aux::unwrap_cv_reference<
342 std::reference_wrapper<test::foo> const
343 >::type
344 , test::foo
345 >
346 , boost::mpl::true_
347 , boost::mpl::false_
348 >::type
349 ));
350 BOOST_MPL_ASSERT((
351 boost::mpl::if_<
352 boost::is_same<
353 boost::parameter::aux::unwrap_cv_reference<
354 std::reference_wrapper<test::foo> volatile
355 >::type
356 , test::foo
357 >
358 , boost::mpl::true_
359 , boost::mpl::false_
360 >::type
361 ));
362 BOOST_MPL_ASSERT((
363 boost::mpl::if_<
364 boost::is_same<
365 boost::parameter::aux::unwrap_cv_reference<
366 std::reference_wrapper<test::foo> const volatile
367 >::type
368 , test::foo
369 >
370 , boost::mpl::true_
371 , boost::mpl::false_
372 >::type
373 ));
374#endif // BOOST_PARAMETER_CAN_USE_MP11
375}
376
377#endif // BOOST_NO_CXX11_HDR_FUNCTIONAL
378
379

source code of boost/libs/parameter/test/unwrap_cv_reference.cpp