lazy_enable_if is not sfinae friendly?
I was surprised to find that the following code doesn't compile with boost 1.55, where boost::result_of is itself sfinae friendly.
template < typename T >
typename boost::lazy_enable_if_c<
boost::is_class<T>::value,
boost::result_of
::type test(int){}
template < typename >
void test(...) {}
struct A{}; // boost::result_of is a valid type that doesn't have a member called "type"
int main(int argc, const char * argv[])
{
test<A>(0); // test<A>(int) meant to be a substitution failure
return 0;
}
For example, on clang++-3.4 with -std=c++11, I got:
clang++-mp-3.4 -std=c++11 -I /opt/local/include/ main.cpp
In file included from main.cpp:1:
In file included from /opt/local/include/boost/type_traits.hpp:65:
In file included from /opt/local/include/boost/type_traits/is_nothrow_move_assignable.hpp:22:
/opt/local/include/boost/utility/enable_if.hpp:40:25: error: no type named 'type' in 'boost::result_of'
typedef typename T::type type;
~~~~~~~~~~~~^~~~
main.cpp:12:1: note: in instantiation of template class 'boost::lazy_enable_if_c
::type::type // when T = A, this is a substitution failure test(int){}
Hui
participants (1)
-
Hui Li