Why doesn't SFINAE (enable_if) work for member functions of a class template?
#include <type_traits> struct A{}; struct B{}; template <typename T> struct Foo { typename std::enable_if<std::is_same<T, A>::value>::type bar() {} typename std::enable_if<std::is_same<T, B>::value>::type bar() {} }; Error message: 14:5: error: 'typename std::enable_if<std::is_same<T, B>::value>::type Foo<T>::bar()' cannot be overloaded 10:5: error: with 'typename std::enable_if<std::is_same<T, A>::value>::type Foo<T>::bar()' Source on cpp.sh . I thought both typename std::enable_if<std::is_same<T,?>::value>::type could not be valid at the same time. Edit For posterity here is my edit based on