1 // Copyright Daniel Wallin 2006.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
6 #include <boost/parameter/config.hpp>
8 #if (BOOST_PARAMETER_MAX_ARITY < 2)
9 #error Define BOOST_PARAMETER_MAX_ARITY as 2 or greater.
11 #if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \
12 (BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < 2)
13 #error Define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \
17 #include <boost/parameter/preprocessor.hpp>
18 #include <boost/parameter/name.hpp>
19 #include <boost/parameter/aux_/preprocessor/nullptr.hpp>
20 #include <boost/tuple/tuple.hpp>
21 #include <boost/core/enable_if.hpp>
24 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
25 #include <boost/mp11/utility.hpp>
26 #include <type_traits>
28 #include <boost/mpl/bool.hpp>
29 #include <boost/mpl/if.hpp>
30 #include <boost/type_traits/is_convertible.hpp>
35 BOOST_PARAMETER_NAME(x
)
37 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
38 template <typename T
, typename Args
>
39 using predicate
= std::is_convertible
<T
,char const*>;
41 BOOST_PARAMETER_FUNCTION((int), sfinae
, test::tag
,
45 , *(boost::mp11::mp_quote
<test::predicate
>)
46 , static_cast<char const*>(BOOST_PARAMETER_AUX_PP_NULLPTR
)
51 #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
54 template <typename T
, typename Args
>
57 boost::is_convertible
<T
,char const*>
65 BOOST_PARAMETER_FUNCTION((int), sfinae
, test::tag
,
70 , static_cast<char const*>(BOOST_PARAMETER_AUX_PP_NULLPTR
)
75 #endif // BOOST_PARAMETER_CAN_USE_MP11
80 template <typename A0
>
81 typename
boost::enable_if
<
82 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
85 typename
boost::mpl::if_
<
86 boost::is_same
<int,A0
>
99 #include <boost/core/lightweight_test.hpp>
103 BOOST_TEST_EQ(1, test::sfinae());
104 BOOST_TEST_EQ(1, test::sfinae("foo"));
105 BOOST_TEST_EQ(0, test::sfinae(1));
106 return boost::report_errors();