-// Copyright Daniel Wallin 2006. Use, modification and distribution is
-// subject to 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)
+// 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 <boost/parameter/config.hpp>
+
+#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 <boost/parameter/preprocessor.hpp>
#include <boost/parameter/name.hpp>
-#include <boost/type_traits/is_convertible.hpp>
+#include <boost/parameter/aux_/preprocessor/nullptr.hpp>
#include <boost/tuple/tuple.hpp>
+#include <boost/core/enable_if.hpp>
#include <string>
-#include "basics.hpp"
-#include <boost/utility/enable_if.hpp>
-
-namespace test {
-
-namespace mpl = boost::mpl;
-
-using mpl::_;
-using boost::is_convertible;
-
-BOOST_PARAMETER_NAME(x)
-
-// Sun has problems with this syntax:
-//
-// template1< r* ( template2<x> ) >
-//
-// Workaround: factor template2<x> into a separate typedef
-
-#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
-
-typedef is_convertible<_,char const*> predicate;
-
-BOOST_PARAMETER_FUNCTION((int), sfinae, tag,
- (deduced
- (optional (x, *(predicate), 0))
- )
-)
-{
- return 1;
-}
+#if defined(BOOST_PARAMETER_CAN_USE_MP11)
+#include <boost/mp11/utility.hpp>
+#include <type_traits>
#else
-
-BOOST_PARAMETER_FUNCTION((int), sfinae, tag,
- (deduced
- (optional (x, *(is_convertible<_,char const*>), 0))
- )
-)
-{
- return 1;
-}
-
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits/is_convertible.hpp>
#endif
-template<class A0>
-typename boost::enable_if<boost::is_same<int,A0>, int>::type
-sfinae(A0 const& a0)
-{
- return 0;
-}
+namespace test {
+ BOOST_PARAMETER_NAME(x)
+
+#if defined(BOOST_PARAMETER_CAN_USE_MP11)
+ template <typename T, typename Args>
+ using predicate = std::is_convertible<T,char const*>;
+
+ BOOST_PARAMETER_FUNCTION((int), sfinae, test::tag,
+ (deduced
+ (optional
+ (x
+ , *(boost::mp11::mp_quote<test::predicate>)
+ , static_cast<char const*>(BOOST_PARAMETER_AUX_PP_NULLPTR)
+ )
+ )
+ )
+ )
+#else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
+ struct predicate
+ {
+ template <typename T, typename Args>
+ struct apply
+ : boost::mpl::if_<
+ boost::is_convertible<T,char const*>
+ , boost::mpl::true_
+ , boost::mpl::false_
+ >
+ {
+ };
+ };
+
+ BOOST_PARAMETER_FUNCTION((int), sfinae, test::tag,
+ (deduced
+ (optional
+ (x
+ , *(test::predicate)
+ , static_cast<char const*>(BOOST_PARAMETER_AUX_PP_NULLPTR)
+ )
+ )
+ )
+ )
+#endif // BOOST_PARAMETER_CAN_USE_MP11
+ {
+ return 1;
+ }
+
+ template <typename A0>
+ typename boost::enable_if<
+#if defined(BOOST_PARAMETER_CAN_USE_MP11)
+ std::is_same<int,A0>
+#else
+ typename boost::mpl::if_<
+ boost::is_same<int,A0>
+ , boost::mpl::true_
+ , boost::mpl::false_
+ >::type
+#endif
+ , int
+ >::type
+ sfinae(A0 const& a0)
+ {
+ return 0;
+ }
} // namespace test
+#include <boost/core/lightweight_test.hpp>
+
int main()
{
- using namespace test;
-
- assert(sfinae() == 1);
- assert(sfinae("foo") == 1);
- assert(sfinae(1) == 0);
-
- return 0;
+ BOOST_TEST_EQ(1, test::sfinae());
+ BOOST_TEST_EQ(1, test::sfinae("foo"));
+ BOOST_TEST_EQ(0, test::sfinae(1));
+ return boost::report_errors();
}