// Copyright Daniel Wallin 2005. // Copyright Cromwell D. Enage 2019. // 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) namespace test { struct default_src { typedef int result_type; int operator()() const { return 0; } }; } // namespace test #include namespace test { BOOST_PARAMETER_NAME(x) BOOST_PARAMETER_NAME(y) BOOST_PARAMETER_NAME(z) } // namespace test #include #include #include #include #include #if defined(BOOST_PARAMETER_CAN_USE_MP11) #include #include #endif namespace test { template void check0(ArgumentPack const& p, K const& kw, T const& value) { #if defined(BOOST_PARAMETER_CAN_USE_MP11) static_assert( !boost::mp11::mp_map_contains::value , "test::tag::z must not be in ArgumentPack" ); static_assert( std::is_same< boost::mp11::mp_map_find , void >::value , "test::tag::z must not be found in ArgumentPack" ); #endif // BOOST_PARAMETER_CAN_USE_MP11 BOOST_MPL_ASSERT((boost::parameter::is_argument_pack)); BOOST_MPL_ASSERT_NOT(( boost::mpl::has_key )); BOOST_TEST_EQ(p[kw], value); } } // namespace test #include #include #include #include #include #include #include #include #include namespace test { template void check1(ArgumentPack const& p, K const& kw, T const& value) { #if defined(BOOST_PARAMETER_CAN_USE_MP11) static_assert( boost::mp11::mp_map_contains::value , "typename K::tag must be in ArgumentPack" ); static_assert( !boost::mp11::mp_map_contains::value , "test::tag::z must not be in ArgumentPack" ); static_assert( !std::is_same< boost::mp11::mp_map_find , void >::value , "typename K::tag must be found in ArgumentPack" ); static_assert( std::is_same< boost::mp11::mp_map_find , void >::value , "test::tag::z must not be found in ArgumentPack" ); #endif // BOOST_PARAMETER_CAN_USE_MP11 BOOST_MPL_ASSERT((boost::parameter::is_argument_pack)); BOOST_MPL_ASSERT((boost::mpl::has_key)); BOOST_MPL_ASSERT_NOT(( boost::mpl::has_key )); BOOST_MPL_ASSERT(( boost::mpl::equal_to< typename boost::mpl::count::type , boost::mpl::int_<1> > )); BOOST_MPL_ASSERT(( typename boost::mpl::if_< boost::is_same< typename boost::mpl ::key_type::type , typename K::tag > , boost::mpl::true_ , boost::mpl::false_ >::type )); BOOST_MPL_ASSERT(( typename boost::mpl::if_< boost::is_same< typename boost::mpl ::order::type , boost::mpl::void_ > , boost::mpl::false_ , boost::mpl::true_ >::type )); BOOST_TEST_EQ(p[kw], value); } } // namespace test int main() { test::check1(test::_x = 20, test::_x, 20); test::check1(test::_y = 20, test::_y, 20); test::check0(test::_x = 20, test::_x | 0, 20); test::check0(test::_y = 20, test::_y | 0, 20); test::check0(test::_x = 20, test::_x || test::default_src(), 20); test::check0(test::_y = 20, test::_y || test::default_src(), 20); test::check0(test::_y = 20, test::_x | 0, 0); test::check0(test::_y = 20, test::_x || test::default_src(), 0); return boost::report_errors(); }