// 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) #include #include #include #include #include #include "basics.hpp" #include 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 ) > // // Workaround: factor template2 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; } #else BOOST_PARAMETER_FUNCTION((int), sfinae, tag, (deduced (optional (x, *(is_convertible<_,char const*>), 0)) ) ) { return 1; } #endif template typename boost::enable_if, int>::type sfinae(A0 const& a0) { return 0; } } // namespace test int main() { using namespace test; assert(sfinae() == 1); assert(sfinae("foo") == 1); assert(sfinae(1) == 0); return 0; }