Boost logo

Boost Users :

Subject: Re: [Boost-users] [mpl, enable_if] "Failed to specialize function template"
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2010-12-14 11:17:47


2010/12/14 Igor R <boost.lists_at_[hidden]>

> 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



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net