// Copyright Daniel Wallin 2006. // 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 #if (BOOST_PARAMETER_MAX_ARITY < 4) #error Define BOOST_PARAMETER_MAX_ARITY as 4 or greater. #endif namespace test { struct X { }; struct Y : X { }; } // namespace test #if defined(BOOST_PARAMETER_CAN_USE_MP11) #include #else #include #include #include #include #include #endif namespace test { struct Z { template #if defined(BOOST_PARAMETER_CAN_USE_MP11) using fn = std::is_base_of< X , typename std::remove_const< typename std::remove_reference::type >::type >; #else struct apply : boost::mpl::if_< boost::is_base_of< X , typename boost::remove_const< typename boost::remove_reference::type >::type > , boost::mpl::true_ , boost::mpl::false_ >::type { }; #endif // BOOST_PARAMETER_CAN_USE_MP11 }; } // namespace test #include namespace test { template struct a0_is : boost::parameter::template_keyword,T> { }; template struct a1_is : boost::parameter::template_keyword,T> { }; template struct a2_is : boost::parameter::template_keyword,T> { }; template struct a3_is : boost::parameter::template_keyword,T> { }; } // namespace test #include #include #include #include namespace test { template < typename A0 = boost::parameter::void_ , typename A1 = boost::parameter::void_ , typename A2 = boost::parameter::void_ , typename A3 = boost::parameter::void_ > struct with_ntp { typedef typename boost::parameter::parameters< test::a0_is<> , test::a1_is<> , test::a2_is<> , boost::parameter::optional< boost::parameter::deduced > , Z > >::BOOST_NESTED_TEMPLATE bind< A0 , A1 , A2 , A3 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) , boost::parameter::void_ #endif >::type args; typedef typename boost::parameter::binding< args , test::a0_is<> , void* >::type a0; typedef typename boost::parameter::binding< args , test::a1_is<> , void* >::type a1; typedef typename boost::parameter::binding< args , test::a2_is<> , void* >::type a2; typedef typename boost::parameter::binding< args , test::a3_is<> , void* >::type a3; typedef void(*type)(a0, a1, a2, a3); }; } // namespace test #include #if !defined(BOOST_PARAMETER_CAN_USE_MP11) #include #include #endif MPL_TEST_CASE() { #if defined(BOOST_PARAMETER_CAN_USE_MP11) static_assert( std::is_same< test::with_ntp<>::type , void(*)(void*, void*, void*, void*) >::value , "type must be void(*)(void*, void*, void*, void*)" ); static_assert( std::is_same< test::with_ntp >::type , void(*)(void*, void*, int, void*) >::value , "type must be void(*)(void*, void*, int, void*)" ); static_assert( std::is_same< test::with_ntp >::type , void(*)(void*, int, void*, void*) >::value , "type must be void(*)(void*, int, void*, void*)" ); static_assert( std::is_same< test::with_ntp,test::a1_is >::type , void(*)(void*, float, int const, void*) >::value , "type must be void(*)(void*, float, int const, void*)" ); static_assert( std::is_same< test::with_ntp::type , void(*)(int const, void*, void*, void*) >::value , "type must be void(*)(int const, void*, void*, void*)" ); static_assert( std::is_same< test::with_ntp::type , void(*)(int, float, void*, void*) >::value , "type must be void(*)(int, float, void*, void*)" ); static_assert( std::is_same< test::with_ntp::type , void(*)(int, float, char, void*) >::value , "type must be void(*)(int, float, char, void*)" ); static_assert( std::is_same< test::with_ntp,test::Y>::type , void(*)(int, void*, void*, test::Y) >::value , "type must be must be void(*)(int, void*, void*, test::Y)" ); static_assert( std::is_same< test::with_ntp,test::Y>::type , void(*)(int&, void*, char, test::Y) >::value , "type must be void(*)(int&, void*, char, test::Y)" ); #else // !defined(BOOST_PARAMETER_CAN_USE_MP11) BOOST_MPL_ASSERT(( boost::mpl::if_< boost::is_same< test::with_ntp<>::type , void(*)(void*, void*, void*, void*) > , boost::mpl::true_ , boost::mpl::false_ >::type )); BOOST_MPL_ASSERT(( boost::mpl::if_< boost::is_same< test::with_ntp >::type , void(*)(void*, void*, int, void*) > , boost::mpl::true_ , boost::mpl::false_ >::type )); BOOST_MPL_ASSERT(( boost::mpl::if_< boost::is_same< test::with_ntp >::type , void(*)(void*, int, void*, void*) > , boost::mpl::true_ , boost::mpl::false_ >::type )); BOOST_MPL_ASSERT(( boost::mpl::if_< boost::is_same< test::with_ntp< test::a2_is , test::a1_is >::type , void(*)(void*, float, int const, void*) > , boost::mpl::true_ , boost::mpl::false_ >::type )); BOOST_MPL_ASSERT(( boost::mpl::if_< boost::is_same< test::with_ntp::type , void(*)(int const, void*, void*, void*) > , boost::mpl::true_ , boost::mpl::false_ >::type )); BOOST_MPL_ASSERT(( boost::mpl::if_< boost::is_same< test::with_ntp::type , void(*)(int, float, void*, void*) > , boost::mpl::true_ , boost::mpl::false_ >::type )); BOOST_MPL_ASSERT(( boost::mpl::if_< boost::is_same< test::with_ntp::type , void(*)(int, float, char, void*) > , boost::mpl::true_ , boost::mpl::false_ >::type )); BOOST_MPL_ASSERT(( boost::mpl::if_< boost::is_same< test::with_ntp,test::Y>::type , void(*)(int, void*, void*, test::Y) > , boost::mpl::true_ , boost::mpl::false_ >::type )); BOOST_MPL_ASSERT(( boost::mpl::if_< boost::is_same< test::with_ntp,test::Y>::type , void(*)(int&, void*, char, test::Y) > , boost::mpl::true_ , boost::mpl::false_ >::type )); #endif // BOOST_PARAMETER_CAN_USE_MP11 typedef int test_array[1]; typedef void(*test_function)(); #if defined(BOOST_PARAMETER_CAN_USE_MP11) static_assert( std::is_same< test::with_ntp::type , void(*)(test_array&, test_function, void*, void*) >::value , "type must be void(*)(test_array&, test_function, void*, void*)" ); #else BOOST_MPL_ASSERT(( boost::mpl::if_< boost::is_same< test::with_ntp::type , void(*)(test_array&, test_function, void*, void*) > , boost::mpl::true_ , boost::mpl::false_ >::type )); #endif }