
2010/12/14 Igor R <boost.lists@gmail.com>
Hello,
The following code fails to compile (MSVC10, Boost 1.45) with "error C2893: Failed to specialize function template..." It seems that the compiler tries to evaluate mpl::apply, doesn't it?
#include <boost/mpl/apply.hpp> #include <boost/mpl/bool.hpp> #include <boost/mpl/or.hpp> #include <boost/mpl/and.hpp> #include <boost/mpl/always.hpp> #include <boost/type_traits/is_same.hpp> #include <boost/utility/enable_if.hpp>
using namespace boost::mpl; using boost::is_same;
template<typename Type> void test(Type, typename boost::enable_if < and_ < not_<boost::is_same<Type, int> >, apply<always<true_>, typename Type::my_type>
::type* dummy = 0)
{ }
template<typename Type> void test(Type, typename boost::disable_if < and_ < not_<boost::is_same<Type, int> >, apply<always<true_>, typename Type::my_type>
::type* dummy = 0)
{ }
int main(int argc, char* argv[]) { test(int()); return 0; }
I thing sfinae should disable the above test() functions for every Type, that doesn't have a nested type my_type. Under mingw-4.5 I get: error: no matching function for call to 'test(int)' Regards, Kris