123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746 |
- // Copyright Rene Rivera 2006.
- // 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/nested_keyword.hpp>
- #include <boost/parameter/name.hpp>
- #include <boost/parameter/config.hpp>
- namespace param {
- BOOST_PARAMETER_NESTED_KEYWORD(tag, a0, a_zero)
- BOOST_PARAMETER_NESTED_KEYWORD(tag, a1, a_one)
- BOOST_PARAMETER_NAME(a2)
- BOOST_PARAMETER_NAME(a3)
- BOOST_PARAMETER_NAME(in(lrc))
- BOOST_PARAMETER_NAME(out(lr))
- #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
- BOOST_PARAMETER_NAME(consume(rr))
- #else
- BOOST_PARAMETER_NAME(rr)
- #endif
- }
- #include <boost/parameter/is_argument_pack.hpp>
- #include <boost/mpl/void.hpp>
- #include <boost/mpl/bool.hpp>
- #include <boost/mpl/int.hpp>
- #include <boost/mpl/if.hpp>
- #include <boost/mpl/has_key.hpp>
- #include <boost/mpl/key_type.hpp>
- #include <boost/mpl/order.hpp>
- #include <boost/mpl/count.hpp>
- #include <boost/mpl/equal_to.hpp>
- #include <boost/mpl/assert.hpp>
- #include <boost/type_traits/is_same.hpp>
- #if defined(BOOST_PARAMETER_CAN_USE_MP11)
- #include <boost/mp11/list.hpp>
- #include <boost/mp11/map.hpp>
- #include <type_traits>
- #endif
- #if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
- #include <boost/function.hpp>
- #else
- #include <functional>
- #endif
- namespace test {
- struct A
- {
- int i;
- int j;
- template <typename ArgPack>
- A(ArgPack const& args) : i(args[param::a0]), j(args[param::a1])
- {
- #if defined(BOOST_PARAMETER_CAN_USE_MP11)
- static_assert(
- boost::mp11::mp_map_contains<ArgPack,param::tag::a0>::value
- , "param::tag::a0 must be in ArgPack"
- );
- static_assert(
- boost::mp11::mp_map_contains<ArgPack,param::tag::a1>::value
- , "param::tag::a1 must be in ArgPack"
- );
- static_assert(
- !boost::mp11::mp_map_contains<ArgPack,param::tag::lrc>::value
- , "param::tag::lrc must not be in ArgPack"
- );
- static_assert(
- !boost::mp11::mp_map_contains<ArgPack,param::tag::lr>::value
- , "param::tag::lr must not be in ArgPack"
- );
- static_assert(
- !boost::mp11::mp_map_contains<ArgPack,param::tag::rr>::value
- , "param::tag::rr must not be in ArgPack"
- );
- static_assert(
- !std::is_same<
- ::boost::mp11::mp_map_find<ArgPack,param::tag::a0>
- , void
- >::value
- , "param::tag::a0 must be found in ArgPack"
- );
- static_assert(
- !std::is_same<
- ::boost::mp11::mp_map_find<ArgPack,param::tag::a1>
- , void
- >::value
- , "param::tag::a1 must be found in ArgPack"
- );
- static_assert(
- std::is_same<
- ::boost::mp11::mp_map_find<ArgPack,param::tag::lrc>
- , void
- >::value
- , "param::tag::lrc must not be found in ArgPack"
- );
- static_assert(
- std::is_same<
- ::boost::mp11::mp_map_find<ArgPack,param::tag::lr>
- , void
- >::value
- , "param::tag::lr must not be found in ArgPack"
- );
- static_assert(
- std::is_same<
- ::boost::mp11::mp_map_find<ArgPack,param::tag::rr>
- , void
- >::value
- , "param::tag::rr must not be found in ArgPack"
- );
- #endif // BOOST_PARAMETER_CAN_USE_MP11
- BOOST_MPL_ASSERT((boost::parameter::is_argument_pack<ArgPack>));
- BOOST_MPL_ASSERT((boost::mpl::has_key<ArgPack,param::tag::a0>));
- BOOST_MPL_ASSERT((boost::mpl::has_key<ArgPack,param::tag::a1>));
- BOOST_MPL_ASSERT_NOT((
- boost::mpl::has_key<ArgPack,param::tag::lrc>
- ));
- BOOST_MPL_ASSERT_NOT((
- boost::mpl::has_key<ArgPack,param::tag::lr>
- ));
- BOOST_MPL_ASSERT_NOT((
- boost::mpl::has_key<ArgPack,param::tag::rr>
- ));
- BOOST_MPL_ASSERT((
- boost::mpl::equal_to<
- typename boost::mpl::count<ArgPack,param::tag::a0>::type
- , boost::mpl::int_<1>
- >
- ));
- BOOST_MPL_ASSERT((
- boost::mpl::equal_to<
- typename boost::mpl::count<ArgPack,param::tag::a1>::type
- , boost::mpl::int_<1>
- >
- ));
- BOOST_MPL_ASSERT((
- typename boost::mpl::if_<
- boost::is_same<
- typename boost::mpl
- ::key_type<ArgPack,param::tag::a0>::type
- , param::tag::a0
- >
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- BOOST_MPL_ASSERT((
- typename boost::mpl::if_<
- boost::is_same<
- typename boost::mpl
- ::key_type<ArgPack,param::tag::a1>::type
- , param::tag::a1
- >
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- BOOST_MPL_ASSERT((
- typename boost::mpl::if_<
- boost::is_same<
- typename boost::mpl
- ::order<ArgPack,param::tag::a0>::type
- , boost::mpl::void_
- >
- , boost::mpl::false_
- , boost::mpl::true_
- >::type
- ));
- BOOST_MPL_ASSERT((
- typename boost::mpl::if_<
- boost::is_same<
- typename boost::mpl
- ::order<ArgPack,param::tag::a1>::type
- , boost::mpl::void_
- >
- , boost::mpl::false_
- , boost::mpl::true_
- >::type
- ));
- }
- };
- float F()
- {
- return 4.0f;
- }
- float E()
- {
- return 4.625f;
- }
- double D()
- {
- return 198.9;
- }
- struct C
- {
- struct result_type
- {
- double operator()() const
- {
- return 2.5;
- }
- };
- result_type operator()() const
- {
- return result_type();
- }
- };
- struct B : A
- {
- #if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
- boost::function<float()> k;
- boost::function<double()> l;
- #else
- std::function<float()> k;
- std::function<double()> l;
- #endif
- template <typename ArgPack>
- B(ArgPack const& args)
- : A((args, param::tag::a0::a_zero = 1))
- , k(args[param::_a2 | E])
- , l(args[param::_a3 || C()])
- {
- }
- };
- struct G
- {
- int i;
- int& j;
- int const& k;
- template <typename ArgPack>
- G(ArgPack const& args)
- : i(args[param::_rr])
- , j(args[param::_lr])
- , k(args[param::_lrc])
- {
- #if defined(BOOST_PARAMETER_CAN_USE_MP11)
- static_assert(
- boost::mp11::mp_map_contains<ArgPack,param::tag::lrc>::value
- , "param::tag::lrc must be in ArgPack"
- );
- static_assert(
- boost::mp11::mp_map_contains<ArgPack,param::tag::lr>::value
- , "param::tag::lr must be in ArgPack"
- );
- static_assert(
- boost::mp11::mp_map_contains<ArgPack,param::tag::rr>::value
- , "param::tag::rr must be in ArgPack"
- );
- static_assert(
- !boost::mp11::mp_map_contains<ArgPack,param::tag::a0>::value
- , "param::tag::a0 must not be in ArgPack"
- );
- static_assert(
- !boost::mp11::mp_map_contains<ArgPack,param::tag::a1>::value
- , "param::tag::a1 must not be in ArgPack"
- );
- static_assert(
- !boost::mp11::mp_map_contains<ArgPack,param::tag::a2>::value
- , "param::tag::a2 must not be in ArgPack"
- );
- static_assert(
- !boost::mp11::mp_map_contains<ArgPack,param::tag::a3>::value
- , "param::tag::a3 must not be in ArgPack"
- );
- static_assert(
- !std::is_same<
- boost::mp11::mp_map_find<ArgPack,param::tag::lrc>
- , void
- >::value
- , "param::tag::lrc must be found in ArgPack"
- );
- static_assert(
- !std::is_same<
- boost::mp11::mp_map_find<ArgPack,param::tag::lr>
- , void
- >::value
- , "param::tag::lr must be found in ArgPack"
- );
- static_assert(
- !std::is_same<
- boost::mp11::mp_map_find<ArgPack,param::tag::rr>
- , void
- >::value
- , "param::tag::rr must be found in ArgPack"
- );
- static_assert(
- std::is_same<
- boost::mp11::mp_map_find<ArgPack,param::tag::a0>
- , void
- >::value
- , "param::tag::a0 must not be found in ArgPack"
- );
- static_assert(
- std::is_same<
- boost::mp11::mp_map_find<ArgPack,param::tag::a1>
- , void
- >::value
- , "param::tag::a1 must not be found in ArgPack"
- );
- static_assert(
- std::is_same<
- boost::mp11::mp_map_find<ArgPack,param::tag::a2>
- , void
- >::value
- , "param::tag::a2 must not be found in ArgPack"
- );
- static_assert(
- std::is_same<
- boost::mp11::mp_map_find<ArgPack,param::tag::a3>
- , void
- >::value
- , "param::tag::a3 must not be found in ArgPack"
- );
- #endif // BOOST_PARAMETER_CAN_USE_MP11
- BOOST_MPL_ASSERT((boost::parameter::is_argument_pack<ArgPack>));
- BOOST_MPL_ASSERT((boost::mpl::has_key<ArgPack,param::tag::rr>));
- BOOST_MPL_ASSERT((boost::mpl::has_key<ArgPack,param::tag::lr>));
- BOOST_MPL_ASSERT((boost::mpl::has_key<ArgPack,param::tag::lrc>));
- BOOST_MPL_ASSERT_NOT((
- boost::mpl::has_key<ArgPack,param::tag::a0>
- ));
- BOOST_MPL_ASSERT_NOT((
- boost::mpl::has_key<ArgPack,param::tag::a1>
- ));
- BOOST_MPL_ASSERT_NOT((
- boost::mpl::has_key<ArgPack,param::tag::a2>
- ));
- BOOST_MPL_ASSERT_NOT((
- boost::mpl::has_key<ArgPack,param::tag::a3>
- ));
- BOOST_MPL_ASSERT((
- boost::mpl::equal_to<
- typename boost::mpl::count<ArgPack,param::tag::rr>::type
- , boost::mpl::int_<1>
- >
- ));
- BOOST_MPL_ASSERT((
- boost::mpl::equal_to<
- typename boost::mpl::count<ArgPack,param::tag::lr>::type
- , boost::mpl::int_<1>
- >
- ));
- BOOST_MPL_ASSERT((
- boost::mpl::equal_to<
- typename boost::mpl::count<ArgPack,param::tag::lrc>::type
- , boost::mpl::int_<1>
- >
- ));
- BOOST_MPL_ASSERT((
- typename boost::mpl::if_<
- boost::is_same<
- typename boost::mpl
- ::key_type<ArgPack,param::tag::rr>::type
- , param::tag::rr
- >
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- BOOST_MPL_ASSERT((
- typename boost::mpl::if_<
- boost::is_same<
- typename boost::mpl
- ::key_type<ArgPack,param::tag::lr>::type
- , param::tag::lr
- >
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- BOOST_MPL_ASSERT((
- typename boost::mpl::if_<
- boost::is_same<
- typename boost::mpl
- ::key_type<ArgPack,param::tag::lrc>::type
- , param::tag::lrc
- >
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- BOOST_MPL_ASSERT((
- typename boost::mpl::if_<
- boost::is_same<
- typename boost::mpl
- ::order<ArgPack,param::tag::rr>::type
- , boost::mpl::void_
- >
- , boost::mpl::false_
- , boost::mpl::true_
- >::type
- ));
- BOOST_MPL_ASSERT((
- typename boost::mpl::if_<
- boost::is_same<
- typename boost::mpl
- ::order<ArgPack,param::tag::lr>::type
- , boost::mpl::void_
- >
- , boost::mpl::false_
- , boost::mpl::true_
- >::type
- ));
- BOOST_MPL_ASSERT((
- typename boost::mpl::if_<
- boost::is_same<
- typename boost::mpl
- ::order<ArgPack,param::tag::lrc>::type
- , boost::mpl::void_
- >
- , boost::mpl::false_
- , boost::mpl::true_
- >::type
- ));
- }
- };
- } // namespace test
- #include <utility>
- namespace test {
- std::pair<int,int> const& lvalue_const_pair()
- {
- static std::pair<int,int> const clp = std::pair<int,int>(7, 10);
- return clp;
- }
- struct H
- {
- std::pair<int,int> i;
- std::pair<int,int>& j;
- std::pair<int,int> const& k;
- template <typename ArgPack>
- H(ArgPack const& args)
- : i(args[param::_rr | test::lvalue_const_pair()])
- , j(args[param::_lr])
- , k(args[param::_lrc])
- {
- #if defined(BOOST_PARAMETER_CAN_USE_MP11)
- static_assert(
- boost::mp11::mp_map_contains<ArgPack,param::tag::lrc>::value
- , "param::tag::lrc must be in ArgPack"
- );
- static_assert(
- boost::mp11::mp_map_contains<ArgPack,param::tag::lr>::value
- , "param::tag::lr must be in ArgPack"
- );
- static_assert(
- !std::is_same<
- boost::mp11::mp_map_find<ArgPack,param::tag::lrc>
- , void
- >::value
- , "param::tag::lrc must be found in ArgPack"
- );
- static_assert(
- !std::is_same<
- boost::mp11::mp_map_find<ArgPack,param::tag::lr>
- , void
- >::value
- , "param::tag::lr must be found in ArgPack"
- );
- #endif // BOOST_PARAMETER_CAN_USE_MP11
- BOOST_MPL_ASSERT((boost::parameter::is_argument_pack<ArgPack>));
- BOOST_MPL_ASSERT((boost::mpl::has_key<ArgPack,param::tag::lr>));
- BOOST_MPL_ASSERT((boost::mpl::has_key<ArgPack,param::tag::lrc>));
- BOOST_MPL_ASSERT((
- boost::mpl::equal_to<
- typename boost::mpl::count<ArgPack,param::tag::lr>::type
- , boost::mpl::int_<1>
- >
- ));
- BOOST_MPL_ASSERT((
- boost::mpl::equal_to<
- typename boost::mpl::count<ArgPack,param::tag::lrc>::type
- , boost::mpl::int_<1>
- >
- ));
- BOOST_MPL_ASSERT((
- typename boost::mpl::if_<
- boost::is_same<
- typename boost::mpl
- ::key_type<ArgPack,param::tag::lr>::type
- , param::tag::lr
- >
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- BOOST_MPL_ASSERT((
- typename boost::mpl::if_<
- boost::is_same<
- typename boost::mpl
- ::key_type<ArgPack,param::tag::lrc>::type
- , param::tag::lrc
- >
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- BOOST_MPL_ASSERT((
- typename boost::mpl::if_<
- boost::is_same<
- typename boost::mpl
- ::order<ArgPack,param::tag::lr>::type
- , boost::mpl::void_
- >
- , boost::mpl::false_
- , boost::mpl::true_
- >::type
- ));
- BOOST_MPL_ASSERT((
- typename boost::mpl::if_<
- boost::is_same<
- typename boost::mpl
- ::order<ArgPack,param::tag::lrc>::type
- , boost::mpl::void_
- >
- , boost::mpl::false_
- , boost::mpl::true_
- >::type
- ));
- }
- };
- } // namespace test
- #include <boost/core/lightweight_test.hpp>
- void test_compose0()
- {
- #if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \
- BOOST_WORKAROUND(BOOST_MSVC, >= 1700) && \
- BOOST_WORKAROUND(BOOST_MSVC, < 1800)
- // MSVC 11.0 on AppVeyor fails without this workaround.
- test::A a((
- param::a0 = 1
- , param::a1 = 13
- , param::_a2 = std::function<double()>(test::D)
- ));
- #else
- test::A a((param::a0 = 1, param::a1 = 13, param::_a2 = test::D));
- #endif
- BOOST_TEST_EQ(1, a.i);
- BOOST_TEST_EQ(13, a.j);
- #if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \
- BOOST_WORKAROUND(BOOST_MSVC, >= 1700) && \
- BOOST_WORKAROUND(BOOST_MSVC, < 1800)
- // MSVC 11.0 on AppVeyor fails without this workaround.
- test::B b0((
- param::tag::a1::a_one = 13
- , param::_a2 = std::function<float()>(test::F)
- ));
- #else
- test::B b0((param::tag::a1::a_one = 13, param::_a2 = test::F));
- #endif
- BOOST_TEST_EQ(1, b0.i);
- BOOST_TEST_EQ(13, b0.j);
- BOOST_TEST_EQ(4.0f, b0.k());
- BOOST_TEST_EQ(2.5, b0.l());
- #if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \
- BOOST_WORKAROUND(BOOST_MSVC, >= 1700) && \
- BOOST_WORKAROUND(BOOST_MSVC, < 1800)
- // MSVC 11.0 on AppVeyor fails without this workaround.
- test::B b1((
- param::_a3 = std::function<double()>(test::D)
- , param::a1 = 13
- ));
- #else
- test::B b1((param::_a3 = test::D, param::a1 = 13));
- #endif
- BOOST_TEST_EQ(1, b1.i);
- BOOST_TEST_EQ(13, b1.j);
- BOOST_TEST_EQ(4.625f, b1.k());
- BOOST_TEST_EQ(198.9, b1.l());
- int x = 23;
- int const y = 42;
- #if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_0)
- test::G g((param::_lr = 15, param::_rr = 16, param::_lrc = y));
- #else
- test::G g((param::_lr = x, param::_rr = 16, param::_lrc = y));
- #endif
- BOOST_TEST_EQ(16, g.i);
- BOOST_TEST_EQ(23, g.j);
- BOOST_TEST_EQ(42, g.k);
- x = 1;
- BOOST_TEST_EQ(1, g.j);
- std::pair<int,int> p1(8, 9);
- std::pair<int,int> const p2(11, 12);
- test::H h0((param::_lr = p1, param::_lrc = p2));
- #if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_1)
- test::H h1((
- param::_lr = p2
- , param::_rr = std::make_pair(7, 10)
- , param::_lrc = p2
- ));
- #else
- test::H h1((
- param::_lr = p1
- , param::_rr = std::make_pair(7, 10)
- , param::_lrc = p2
- ));
- #endif
- BOOST_TEST_EQ(h0.i.first, h1.i.first);
- BOOST_TEST_EQ(h0.i.second, h1.i.second);
- BOOST_TEST_EQ(p1.first, h1.j.first);
- BOOST_TEST_EQ(p1.second, h1.j.second);
- BOOST_TEST_EQ(p2.first, h1.k.first);
- BOOST_TEST_EQ(p2.second, h1.k.second);
- p1.first = 1;
- BOOST_TEST_EQ(p1.first, h1.j.first);
- }
- #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) || \
- (2 < BOOST_PARAMETER_COMPOSE_MAX_ARITY)
- #include <boost/parameter/compose.hpp>
- void test_compose1()
- {
- #if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \
- BOOST_WORKAROUND(BOOST_MSVC, >= 1700) && \
- BOOST_WORKAROUND(BOOST_MSVC, < 1800)
- // MSVC 11.0 on AppVeyor fails without this workaround.
- test::A a(boost::parameter::compose(
- param::a0 = 1
- , param::a1 = 13
- , param::_a2 = std::function<double()>(test::D)
- ));
- #else
- test::A a(boost::parameter::compose(
- param::a0 = 1
- , param::a1 = 13
- , param::_a2 = test::D
- ));
- #endif
- BOOST_TEST_EQ(1, a.i);
- BOOST_TEST_EQ(13, a.j);
- #if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \
- BOOST_WORKAROUND(BOOST_MSVC, >= 1700) && \
- BOOST_WORKAROUND(BOOST_MSVC, < 1800)
- // MSVC 11.0 on AppVeyor fails without this workaround.
- test::B b0(boost::parameter::compose(
- param::tag::a1::a_one = 13
- , param::_a2 = std::function<float()>(test::F)
- ));
- #else
- test::B b0(boost::parameter::compose(
- param::tag::a1::a_one = 13
- , param::_a2 = test::F
- ));
- #endif
- BOOST_TEST_EQ(1, b0.i);
- BOOST_TEST_EQ(13, b0.j);
- BOOST_TEST_EQ(4.0f, b0.k());
- BOOST_TEST_EQ(2.5, b0.l());
- #if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \
- BOOST_WORKAROUND(BOOST_MSVC, >= 1700) && \
- BOOST_WORKAROUND(BOOST_MSVC, < 1800)
- // MSVC 11.0 on AppVeyor fails without this workaround.
- test::B b1(boost::parameter::compose(
- param::_a3 = std::function<double()>(test::D)
- , param::a1 = 13
- ));
- #else
- test::B b1(boost::parameter::compose(
- param::_a3 = test::D
- , param::a1 = 13
- ));
- #endif
- BOOST_TEST_EQ(1, b1.i);
- BOOST_TEST_EQ(13, b1.j);
- BOOST_TEST_EQ(4.625f, b1.k());
- BOOST_TEST_EQ(198.9, b1.l());
- int x = 23;
- int const y = 42;
- #if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_0)
- test::G g(boost::parameter::compose(
- param::_lr = 15
- , param::_rr = 16
- , param::_lrc = y
- ));
- #else
- test::G g(boost::parameter::compose(
- param::_lr = x
- , param::_rr = 16
- , param::_lrc = y
- ));
- #endif
- BOOST_TEST_EQ(16, g.i);
- BOOST_TEST_EQ(23, g.j);
- BOOST_TEST_EQ(42, g.k);
- x = 1;
- BOOST_TEST_EQ(1, g.j);
- std::pair<int,int> p1(8, 9);
- std::pair<int,int> const p2(11, 12);
- test::H h0(boost::parameter::compose(param::_lr = p1, param::_lrc = p2));
- #if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_1)
- test::H h1(boost::parameter::compose(
- param::_lr = p2
- , param::_rr = std::make_pair(7, 10)
- , param::_lrc = p2
- ));
- #else
- test::H h1(boost::parameter::compose(
- param::_lr = p1
- , param::_rr = std::make_pair(7, 10)
- , param::_lrc = p2
- ));
- #endif
- BOOST_TEST_EQ(h0.i.first, h1.i.first);
- BOOST_TEST_EQ(h0.i.second, h1.i.second);
- BOOST_TEST_EQ(p1.first, h1.j.first);
- BOOST_TEST_EQ(p1.second, h1.j.second);
- BOOST_TEST_EQ(p2.first, h1.k.first);
- BOOST_TEST_EQ(p2.second, h1.k.second);
- p1.first = 1;
- BOOST_TEST_EQ(p1.first, h1.j.first);
- }
- #endif // can invoke boost::parameter::compose
- int main()
- {
- test_compose0();
- #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) || \
- (2 < BOOST_PARAMETER_COMPOSE_MAX_ARITY)
- test_compose1();
- #endif
- return boost::report_errors();
- }
|