1 // Copyright Cromwell D. Enage 2018.
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)
6 #include <boost/parameter/config.hpp>
8 #if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \
9 (BOOST_PARAMETER_COMPOSE_MAX_ARITY < 8)
10 #error Define BOOST_PARAMETER_COMPOSE_MAX_ARITY as 8 or greater.
13 #include <boost/parameter/name.hpp>
17 BOOST_PARAMETER_NAME((_lrc0
, kw0
) in(lrc0
))
18 BOOST_PARAMETER_NAME((_lr0
, kw1
) in_out(lr0
))
19 BOOST_PARAMETER_NAME((_rrc0
, kw2
) in(rrc0
))
20 #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
21 BOOST_PARAMETER_NAME((_rr0
, kw3
) consume(rr0
))
23 BOOST_PARAMETER_NAME((_rr0
, kw3
) rr0
)
25 BOOST_PARAMETER_NAME((_lrc1
, kw4
) in(lrc1
))
26 BOOST_PARAMETER_NAME((_lr1
, kw5
) out(lr1
))
27 BOOST_PARAMETER_NAME((_rrc1
, kw6
) in(rrc1
))
28 BOOST_PARAMETER_NAME((_rr1
, kw7
) rr1
)
31 #include <boost/parameter/preprocessor_no_spec.hpp>
32 #include <boost/parameter/value_type.hpp>
33 #include <boost/core/lightweight_test.hpp>
34 #include <boost/type_traits/is_scalar.hpp>
35 #include <boost/type_traits/remove_const.hpp>
36 #include "evaluate_category.hpp"
40 BOOST_PARAMETER_NO_SPEC_FUNCTION((bool), evaluate
)
43 test::passed_by_lvalue_reference_to_const
== test::A
<
44 typename
boost::remove_const
<
45 typename
boost::parameter::value_type
<
50 >::evaluate_category(args
[test::_lrc0
])
53 test::passed_by_lvalue_reference
== test::A
<
54 typename
boost::remove_const
<
55 typename
boost::parameter::value_type
<
60 >::evaluate_category(args
[test::_lr0
])
63 #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
66 typename
boost::remove_const
<
67 typename
boost::parameter::value_type
<
76 test::passed_by_lvalue_reference_to_const
== test::A
<
77 typename
boost::remove_const
<
78 typename
boost::parameter::value_type
<
83 >::evaluate_category(args
[test::_rrc0
])
86 test::passed_by_lvalue_reference_to_const
== test::A
<
87 typename
boost::remove_const
<
88 typename
boost::parameter::value_type
<
93 >::evaluate_category(args
[test::_rr0
])
96 else // rrc0's value type isn't scalar
99 test::passed_by_rvalue_reference_to_const
== test::A
<
100 typename
boost::remove_const
<
101 typename
boost::parameter::value_type
<
106 >::evaluate_category(args
[test::_rrc0
])
109 test::passed_by_rvalue_reference
== test::A
<
110 typename
boost::remove_const
<
111 typename
boost::parameter::value_type
<
116 >::evaluate_category(args
[test::_rr0
])
119 #else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
121 test::passed_by_lvalue_reference_to_const
== test::A
<
122 typename
boost::remove_const
<
123 typename
boost::parameter::value_type
<
128 >::evaluate_category(args
[test::_rrc0
])
131 test::passed_by_lvalue_reference_to_const
== test::A
<
132 typename
boost::remove_const
<
133 typename
boost::parameter::value_type
<
138 >::evaluate_category(args
[test::_rr0
])
140 #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING
146 #include <boost/mpl/bool.hpp>
147 #include <boost/mpl/if.hpp>
149 #if !defined(BOOST_NO_SFINAE)
150 #include <boost/parameter/aux_/preprocessor/nullptr.hpp>
151 #include <boost/core/enable_if.hpp>
152 #include <boost/type_traits/is_base_of.hpp>
157 char const* baz
= "baz";
161 #if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \
162 BOOST_WORKAROUND(BOOST_MSVC, >= 1800)
168 template <typename Args
>
171 #if !defined(BOOST_NO_SFINAE)
172 , typename
boost::disable_if
<
173 typename
boost::mpl::if_
<
174 boost::is_base_of
<B
,Args
>
178 >::type
* = BOOST_PARAMETER_AUX_PP_NULLPTR
179 #endif // BOOST_NO_SFINAE
183 test::_lrc0
= args
[test::_lrc0
]
184 , test::_lr0
= args
[test::_lr0
]
185 , test::_rrc0
= args
[test::_rrc0
]
186 , test::_rr0
= args
[test::_rr0
]
190 BOOST_PARAMETER_NO_SPEC_MEMBER_FUNCTION((bool), static evaluate
)
193 test::passed_by_lvalue_reference_to_const
== test::A
<
194 typename
boost::remove_const
<
195 typename
boost::parameter::value_type
<
200 >::evaluate_category(args
[test::_lrc0
])
203 test::passed_by_lvalue_reference
== test::A
<
204 typename
boost::remove_const
<
205 typename
boost::parameter::value_type
<
211 >::evaluate_category(args
[test::_lr0
| test::baz
])
214 test::passed_by_lvalue_reference_to_const
== test::A
<
215 typename
boost::remove_const
<
216 typename
boost::parameter::value_type
<
222 >::evaluate_category(args
[test::_rrc0
| 0.0f
])
225 #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
227 test::passed_by_rvalue_reference
== test::A
<
228 typename
boost::remove_const
<
229 typename
boost::parameter::value_type
<
235 >::evaluate_category(
237 test::_rr0
| std::string(args
[test::_lr0
| test::baz
])
241 #else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
243 test::passed_by_lvalue_reference_to_const
== test::A
<
244 typename
boost::remove_const
<
245 typename
boost::parameter::value_type
<
251 >::evaluate_category(
253 test::_rr0
| std::string(args
[test::_lr0
| test::baz
])
257 #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING
265 #if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \
266 BOOST_WORKAROUND(BOOST_MSVC, >= 1800)
272 BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR(C
, (B
))
277 BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR(D
, D::_evaluate
)
279 BOOST_PARAMETER_NO_SPEC_CONST_MEMBER_FUNCTION((bool), evaluate_m
)
281 return D::_evaluate(args
);
284 BOOST_PARAMETER_NO_SPEC_CONST_FUNCTION_CALL_OPERATOR((bool))
286 return D::_evaluate(args
);
290 template <typename Args
>
291 static bool _evaluate(Args
const& args
)
294 test::passed_by_lvalue_reference_to_const
295 , test::U::evaluate_category
<0>(args
[test::_lrc0
])
298 test::passed_by_lvalue_reference
299 , test::U::evaluate_category
<1>(args
[test::_lr0
])
302 test::passed_by_lvalue_reference_to_const
303 , test::U::evaluate_category
<4>(args
[test::_lrc1
])
306 test::passed_by_lvalue_reference
307 , test::U::evaluate_category
<5>(
308 args
[test::_lr1
| test::lvalue_bitset
<5>()]
311 #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
313 test::passed_by_rvalue_reference_to_const
314 , test::U::evaluate_category
<2>(args
[test::_rrc0
])
317 test::passed_by_rvalue_reference
318 , test::U::evaluate_category
<3>(args
[test::_rr0
])
321 test::passed_by_rvalue_reference_to_const
322 , test::U::evaluate_category
<6>(
323 args
[test::_rrc1
| test::rvalue_const_bitset
<6>()]
327 test::passed_by_rvalue_reference
328 , test::U::evaluate_category
<7>(
329 args
[test::_rr1
| test::rvalue_bitset
<7>()]
332 #else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
334 test::passed_by_lvalue_reference_to_const
335 , test::U::evaluate_category
<2>(args
[test::_rrc0
])
338 test::passed_by_lvalue_reference_to_const
339 , test::U::evaluate_category
<3>(args
[test::_rr0
])
342 test::passed_by_lvalue_reference_to_const
343 , test::U::evaluate_category
<6>(
344 args
[test::_rrc1
| test::rvalue_const_bitset
<6>()]
348 test::passed_by_lvalue_reference_to_const
349 , test::U::evaluate_category
<7>(
350 args
[test::_rr1
| test::rvalue_bitset
<7>()]
353 #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING
363 test::_lr0
= test::lvalue_float()
364 , test::_rrc0
= test::rvalue_const_float()
365 , test::_rr0
= test::rvalue_float()
366 , test::_lrc0
= test::lvalue_const_float()
369 test::_lr0
= test::lvalue_char_ptr()
370 , test::_rrc0
= test::rvalue_const_char_ptr()
371 , test::_rr0
= test::rvalue_char_ptr()
372 , test::_lrc0
= test::lvalue_const_char_ptr()
375 test::_lr0
= test::lvalue_str()
376 , test::_rrc0
= test::rvalue_const_str()
377 , test::_rr0
= test::rvalue_str()
378 , test::_lrc0
= test::lvalue_const_str()
382 test::_lr0
= test::lvalue_float()
383 , test::_rrc0
= test::rvalue_const_float()
384 , test::_rr0
= test::rvalue_float()
385 , test::_lrc0
= test::lvalue_const_float()
388 test::_lr0
= test::lvalue_char_ptr()
389 , test::_rrc0
= test::rvalue_const_char_ptr()
390 , test::_rr0
= test::rvalue_char_ptr()
391 , test::_lrc0
= test::lvalue_const_char_ptr()
394 test::_lr0
= test::lvalue_str()
395 , test::_rrc0
= test::rvalue_const_str()
396 , test::_rr0
= test::rvalue_str()
397 , test::_lrc0
= test::lvalue_const_str()
400 char baz_arr
[4] = "qux";
401 typedef char char_arr
[4];
403 #if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && ( \
404 BOOST_WORKAROUND(BOOST_GCC, < 40000) || \
405 BOOST_WORKAROUND(BOOST_MSVC, >= 1800) \
407 // MSVC-12+ treats static_cast<char_arr&&>(baz_arr) as an lvalue.
408 // GCC 3- tries to bind string literals
409 // to non-const references to char const*.
413 #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
414 , test::_rrc0
= static_cast<char_arr
const&&>("def")
415 , test::_rr0
= static_cast<char_arr
&&>(baz_arr
)
417 , test::_rrc0
= "grl"
420 , test::_lrc0
= "wld"
423 test::B::evaluate(test::_lrc0
= test::lvalue_const_str()[0]);
425 test::_rrc0
= test::rvalue_const_float()
426 , test::_lrc0
= test::lvalue_const_str()[0]
429 #if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \
430 BOOST_WORKAROUND(BOOST_MSVC, >= 1800)
431 // MSVC-12+ treats static_cast<char_arr&&>(baz_arr) as an lvalue.
437 , test::_lr0
= baz_arr
438 #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
439 , test::_rrc0
= static_cast<char_arr
const&&>("dfs")
440 , test::_rr0
= static_cast<char_arr
&&>(baz_arr
)
442 , test::_rrc0
= "plg"
448 #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
449 , test::_rrc0
= static_cast<char_arr
const&&>("dgx")
450 , test::_rr0
= static_cast<char_arr
&&>(baz_arr
)
452 , test::_rrc0
= "hnk"
455 , test::_lrc0
= "zts"
460 test::_lrc0
= test::lvalue_const_str()[0]
461 , test::_lr0
= test::lvalue_char_ptr()
462 , test::_rr0
= test::rvalue_str()
463 , test::_rrc0
= test::rvalue_const_float()
466 test::_lrc0
= test::lvalue_const_str()[0]
467 , test::_rr0
= test::rvalue_str()
468 , test::_rrc0
= test::rvalue_const_float()
469 , test::_lr0
= test::lvalue_char_ptr()
473 test::_lrc1
= test::lvalue_const_bitset
<4>()
474 , test::_lrc0
= test::lvalue_const_bitset
<0>()
475 , test::_lr0
= test::lvalue_bitset
<1>()
476 , test::_rrc0
= test::rvalue_const_bitset
<2>()
477 , test::_rr0
= test::rvalue_bitset
<3>()
480 test::_lrc1
= test::lvalue_const_bitset
<4>()
481 , test::_lrc0
= test::lvalue_const_bitset
<0>()
482 , test::_rrc1
= test::rvalue_const_bitset
<6>()
483 , test::_lr0
= test::lvalue_bitset
<1>()
484 , test::_rrc0
= test::rvalue_const_bitset
<2>()
485 , test::_rr0
= test::rvalue_bitset
<3>()
489 test::_lrc1
= test::lvalue_const_bitset
<4>()
490 , test::_lrc0
= test::lvalue_const_bitset
<0>()
491 , test::_rrc1
= test::rvalue_const_bitset
<6>()
492 , test::_lr0
= test::lvalue_bitset
<1>()
493 , test::_rrc0
= test::rvalue_const_bitset
<2>()
494 , test::_rr0
= test::rvalue_bitset
<3>()
497 test::_lr0
= test::lvalue_bitset
<1>()
498 , test::_rrc0
= test::rvalue_const_bitset
<2>()
499 , test::_rr0
= test::rvalue_bitset
<3>()
500 , test::_lrc1
= test::lvalue_const_bitset
<4>()
501 , test::_lr1
= test::lvalue_bitset
<5>()
502 , test::_rrc1
= test::rvalue_const_bitset
<6>()
503 , test::_rr1
= test::rvalue_bitset
<7>()
504 , test::_lrc0
= test::lvalue_const_bitset
<0>()
507 test::_lrc1
= test::lvalue_const_bitset
<4>()
508 , test::_lrc0
= test::lvalue_const_bitset
<0>()
509 , test::_lr0
= test::lvalue_bitset
<1>()
510 , test::_rrc0
= test::rvalue_const_bitset
<2>()
511 , test::_rr0
= test::rvalue_bitset
<3>()
514 test::_lr0
= test::lvalue_bitset
<1>()
515 , test::_rrc0
= test::rvalue_const_bitset
<2>()
516 , test::_rr0
= test::rvalue_bitset
<3>()
517 , test::_lrc1
= test::lvalue_const_bitset
<4>()
518 , test::_lr1
= test::lvalue_bitset
<5>()
519 , test::_rrc1
= test::rvalue_const_bitset
<6>()
520 , test::_rr1
= test::rvalue_bitset
<7>()
521 , test::_lrc0
= test::lvalue_const_bitset
<0>()
523 return boost::report_errors();