123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- // Copyright Cromwell D. Enage 2017.
- // Distributed under the Boost Software License, Version 1.0.
- // (See accompanying file LICENSE_1_0.txt or copy at
- // http://www.boost.org/LICENSE_1_0.txt)
- #include <boost/parameter/config.hpp>
- #if (BOOST_PARAMETER_MAX_ARITY < 4)
- #error Define BOOST_PARAMETER_MAX_ARITY as 4 or greater.
- #endif
- #if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \
- (BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < 5)
- #error Define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \
- as 5 or greater.
- #endif
- #include <boost/parameter/name.hpp>
- namespace test {
- BOOST_PARAMETER_NAME((_lrc0, keywords) in(lrc0))
- BOOST_PARAMETER_NAME((_lr0, keywords) in_out(lr0))
- BOOST_PARAMETER_NAME((_rrc0, keywords) in(rrc0))
- #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
- BOOST_PARAMETER_NAME((_rr0, keywords) consume(rr0))
- #else
- BOOST_PARAMETER_NAME((_rr0, keywords) rr0)
- #endif
- } // namespace test
- #include <boost/parameter/parameters.hpp>
- #include <boost/parameter/required.hpp>
- namespace test {
- struct f_parameters
- : boost::parameter::parameters<
- boost::parameter::required<test::keywords::lrc0>
- , boost::parameter::required<test::keywords::lr0>
- , boost::parameter::required<test::keywords::rrc0>
- , boost::parameter::required<test::keywords::rr0>
- >
- {
- };
- } // namespace test
- #include <boost/core/lightweight_test.hpp>
- #include "evaluate_category.hpp"
- #if defined(BOOST_PARAMETER_CAN_USE_MP11)
- #include <type_traits>
- #else
- #include <boost/type_traits/is_scalar.hpp>
- #endif
- namespace test {
- template <typename T>
- struct B
- {
- template <typename Args>
- static void evaluate(Args const& args)
- {
- BOOST_TEST_EQ(
- test::passed_by_lvalue_reference_to_const
- , test::A<T>::evaluate_category(args[test::_lrc0])
- );
- BOOST_TEST_EQ(
- test::passed_by_lvalue_reference
- , test::A<T>::evaluate_category(args[test::_lr0])
- );
- #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
- #if defined(BOOST_PARAMETER_CAN_USE_MP11)
- if (std::is_scalar<T>::value)
- #else
- if (boost::is_scalar<T>::value)
- #endif
- {
- BOOST_TEST_EQ(
- test::passed_by_lvalue_reference_to_const
- , test::A<T>::evaluate_category(args[test::_rrc0])
- );
- BOOST_TEST_EQ(
- test::passed_by_lvalue_reference_to_const
- , test::A<T>::evaluate_category(args[test::_rr0])
- );
- }
- else
- {
- BOOST_TEST_EQ(
- test::passed_by_rvalue_reference_to_const
- , test::A<T>::evaluate_category(args[test::_rrc0])
- );
- BOOST_TEST_EQ(
- test::passed_by_rvalue_reference
- , test::A<T>::evaluate_category(args[test::_rr0])
- );
- }
- #else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
- BOOST_TEST_EQ(
- test::passed_by_lvalue_reference_to_const
- , test::A<T>::evaluate_category(args[test::_rrc0])
- );
- BOOST_TEST_EQ(
- test::passed_by_lvalue_reference_to_const
- , test::A<T>::evaluate_category(args[test::_rr0])
- );
- #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING
- }
- };
- } // namespace test
- #include <boost/parameter/deduced.hpp>
- #include <boost/mpl/bool.hpp>
- #include <boost/mpl/placeholders.hpp>
- #include <boost/mpl/if.hpp>
- #include <boost/type_traits/is_convertible.hpp>
- #if defined(BOOST_PARAMETER_CAN_USE_MP11)
- #include <boost/mp11/bind.hpp>
- #endif
- namespace test {
- struct e_parameters
- : boost::parameter::parameters<
- boost::parameter::required<
- boost::parameter::deduced<test::keywords::lrc0>
- #if defined(BOOST_PARAMETER_CAN_USE_MP11)
- , boost::mp11::mp_bind<
- std::is_convertible
- , boost::mp11::_1
- , float
- >
- #else
- , boost::mpl::if_<
- boost::is_convertible<boost::mpl::_1,float>
- , boost::mpl::true_
- , boost::mpl::false_
- >
- #endif
- >
- , boost::parameter::required<
- boost::parameter::deduced<test::keywords::lr0>
- , boost::mpl::if_<
- boost::is_convertible<boost::mpl::_1,char const*>
- , boost::mpl::true_
- , boost::mpl::false_
- >
- >
- , boost::parameter::required<
- boost::parameter::deduced<test::keywords::rr0>
- , test::string_predicate<test::keywords::lr0>
- >
- >
- {
- };
- } // namespace test
- #include <boost/parameter/value_type.hpp>
- #if !defined(BOOST_PARAMETER_CAN_USE_MP11)
- #include <boost/type_traits/remove_const.hpp>
- #endif
- namespace test {
- struct E
- {
- template <typename Args>
- static void evaluate(Args const& args)
- {
- #if defined(BOOST_PARAMETER_CAN_USE_MP11)
- BOOST_TEST((
- test::passed_by_lvalue_reference_to_const == test::A<
- typename std::remove_const<
- typename boost::parameter::value_type<
- Args
- , test::keywords::lrc0
- >::type
- >::type
- >::evaluate_category(args[test::_lrc0])
- ));
- BOOST_TEST((
- test::passed_by_lvalue_reference == test::A<
- typename std::remove_const<
- typename boost::parameter::value_type<
- Args
- , test::keywords::lr0
- >::type
- >::type
- >::evaluate_category(args[test::_lr0])
- ));
- #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
- BOOST_TEST((
- test::passed_by_lvalue_reference_to_const == test::A<
- typename boost::remove_const<
- typename boost::parameter::value_type<
- Args
- , test::keywords::lrc0
- >::type
- >::type
- >::evaluate_category(args[test::_lrc0])
- ));
- BOOST_TEST((
- test::passed_by_lvalue_reference == test::A<
- typename boost::remove_const<
- typename boost::parameter::value_type<
- Args
- , test::keywords::lr0
- >::type
- >::type
- >::evaluate_category(args[test::_lr0])
- ));
- #endif // BOOST_PARAMETER_CAN_USE_MP11
- #if defined(BOOST_PARAMETER_CAN_USE_MP11)
- BOOST_TEST((
- test::passed_by_rvalue_reference == test::A<
- typename std::remove_const<
- typename boost::parameter::value_type<
- Args
- , test::keywords::rr0
- >::type
- >::type
- >::evaluate_category(args[test::_rr0])
- ));
- #elif defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
- BOOST_TEST((
- test::passed_by_rvalue_reference == test::A<
- typename boost::remove_const<
- typename boost::parameter::value_type<
- Args
- , test::keywords::rr0
- >::type
- >::type
- >::evaluate_category(args[test::_rr0])
- ));
- #else // no MP11 or perfect forwarding support
- BOOST_TEST((
- test::passed_by_lvalue_reference_to_const == test::A<
- typename boost::remove_const<
- typename boost::parameter::value_type<
- Args
- , test::keywords::rr0
- >::type
- >::type
- >::evaluate_category(args[test::_rr0])
- ));
- #endif // MP11 or perfect forwarding support
- }
- };
- } // namespace test
- int main()
- {
- test::B<float>::evaluate(
- test::f_parameters()(
- test::lvalue_const_float()
- , test::lvalue_float()
- , test::rvalue_const_float()
- , test::rvalue_float()
- )
- );
- test::B<char const*>::evaluate(
- test::f_parameters()(
- test::lvalue_const_char_ptr()
- , test::lvalue_char_ptr()
- , test::rvalue_const_char_ptr()
- , test::rvalue_char_ptr()
- )
- );
- test::B<std::string>::evaluate(
- test::f_parameters()(
- test::lvalue_const_str()
- , test::lvalue_str()
- , test::rvalue_const_str()
- , test::rvalue_str()
- )
- );
- test::B<float>::evaluate((
- test::_lr0 = test::lvalue_float()
- , test::_rrc0 = test::rvalue_const_float()
- , test::_rr0 = test::rvalue_float()
- , test::_lrc0 = test::lvalue_const_float()
- ));
- test::B<char const*>::evaluate((
- test::_lr0 = test::lvalue_char_ptr()
- , test::_rrc0 = test::rvalue_const_char_ptr()
- , test::_rr0 = test::rvalue_char_ptr()
- , test::_lrc0 = test::lvalue_const_char_ptr()
- ));
- test::B<std::string>::evaluate((
- test::_lr0 = test::lvalue_str()
- , test::_rrc0 = test::rvalue_const_str()
- , test::_rr0 = test::rvalue_str()
- , test::_lrc0 = test::lvalue_const_str()
- ));
- char baz_arr[4] = "qux";
- typedef char char_arr[4];
- #if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \
- BOOST_WORKAROUND(BOOST_MSVC, >= 1800)
- // MSVC-12+ treats static_cast<char_arr&&>(baz_arr) as an lvalue.
- #else
- test::B<char_arr>::evaluate(
- test::f_parameters()(
- "crg"
- , baz_arr
- #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
- , static_cast<char_arr const&&>("uir")
- , static_cast<char_arr&&>(baz_arr)
- #else
- , "grl"
- , "grp"
- #endif
- )
- );
- test::B<char_arr>::evaluate((
- test::_lr0 = baz_arr
- #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
- , test::_rrc0 = static_cast<char_arr const&&>("wld")
- , test::_rr0 = static_cast<char_arr&&>(baz_arr)
- #else
- , test::_rrc0 = "frd"
- , test::_rr0 = "plg"
- #endif
- , test::_lrc0 = "mos"
- ));
- #endif // MSVC-12+
- test::E::evaluate(
- test::e_parameters()(
- test::lvalue_char_ptr()
- , test::rvalue_str()
- , test::lvalue_const_float()
- )
- );
- test::E::evaluate(
- test::e_parameters()(
- test::rvalue_str()
- , test::lvalue_const_float()
- , test::lvalue_char_ptr()
- )
- );
- return boost::report_errors();
- }
|