template<typename T> struct is_int { static const bool value = false; };
template <> struct is_int<int> { static const bool value = true; }; template <bool Cond, typename T = void> struct enable_if {}; template <typename T> struct enable_if<true, T> { typedef T type; }; class test { public: template <typename T> typename enable_if<is_int<T>::value>::type func(T x) {} template <typename T> typename enable_if<!is_int<T>::value>::type func(T x) {} }; fails to compile on 4.0.2 with t2.cpp:29: error: template<class T> typename enable_if<(! is_int<T>::value), void>::type test::func(T) cannot be overloaded t2.cpp:25: error: with template<class T> typename enable_if<is_int<T>::value, void>::type test::func(T) fails to compile on 3.4.2 with t2.cpp:30: error: `template<class T> typename enable_if<(! is_int<T>::value), void>::type test::func(T)' and `template<class T> typename enable_if< is_int<T>::value, void>::type test::func(T)' cannot be overloaded However the same two functions will compile when not defined as part of a class <insert the enable_if and is_int from above> template <typename T> typename enable_if<is_int<T>::value>::type func(T x) {} template <typename T> typename enable_if<!is_int<T>::value>::type func(T x) {} both msvc7.1 and Comeau 4.3.3 will accept it. I don't think that this is duplicate of 15882. The problem appears to be that syntax checking is catching this before SFINAE has a chance to prune the overload set. At any rate there are not template instantiations in the test case. -- Summary: Overload errors generated without template instantiations for class member templates Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: nem3 at pitt dot edu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24915