SFINAE not working to conditionally compile member function template
问题 I'm trying you use std::enable_if to conditionally choose only one out of two member function template using SFINAE with this code: #include <iostream> #include <type_traits> template<typename T> struct C { template<typename Q = T, typename = typename std::enable_if<std::is_same<Q, int>::value>::type> int foo() { return 1; } template<typename Q = T, typename = typename std::enable_if<!std::is_same<Q, int>::value>::type> int foo() { return 0; } }; int main() { std::cout << C<int>().foo() <<