// 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 < 2) #error Define BOOST_PARAMETER_MAX_ARITY as 2 or greater. #endif #if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \ (BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < 2) #error Define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \ as 2 or greater. #endif #include #include #include #include #include #include #if defined(BOOST_PARAMETER_CAN_USE_MP11) #include #include #else #include #include #include #endif namespace test { BOOST_PARAMETER_NAME(x) #if defined(BOOST_PARAMETER_CAN_USE_MP11) template using predicate = std::is_convertible; BOOST_PARAMETER_FUNCTION((int), sfinae, test::tag, (deduced (optional (x , *(boost::mp11::mp_quote) , static_cast(BOOST_PARAMETER_AUX_PP_NULLPTR) ) ) ) ) #else // !defined(BOOST_PARAMETER_CAN_USE_MP11) struct predicate { template struct apply : boost::mpl::if_< boost::is_convertible , boost::mpl::true_ , boost::mpl::false_ > { }; }; BOOST_PARAMETER_FUNCTION((int), sfinae, test::tag, (deduced (optional (x , *(test::predicate) , static_cast(BOOST_PARAMETER_AUX_PP_NULLPTR) ) ) ) ) #endif // BOOST_PARAMETER_CAN_USE_MP11 { return 1; } template typename boost::enable_if< #if defined(BOOST_PARAMETER_CAN_USE_MP11) std::is_same #else typename boost::mpl::if_< boost::is_same , boost::mpl::true_ , boost::mpl::false_ >::type #endif , int >::type sfinae(A0 const& a0) { return 0; } } // namespace test #include int main() { BOOST_TEST_EQ(1, test::sfinae()); BOOST_TEST_EQ(1, test::sfinae("foo")); BOOST_TEST_EQ(0, test::sfinae(1)); return boost::report_errors(); }