Community
Participate
Working Groups
A simple modification to the example from comment 2 to https://bugs.eclipse.org/bugs/show_bug.cgi?id=365981 still produces an error: template <bool, typename _Tp = void> struct enable_if { }; template <typename _Tp> struct enable_if<true, _Tp> { typedef _Tp type; }; template <typename T, typename Signature> struct has_foo { template <typename U, U> struct type_check; template <typename X> static char (& chk(type_check<Signature, &X::foo> *))[1]; template <typename > static char (& chk(...))[2]; static bool const value = sizeof(chk<T>(0)) == 1; }; template <typename T> bool bar(T); template <typename T> bool bar(T, typename enable_if<!has_foo<T, void(T::*)()>::value>::type* = 0); struct S { void foo(); }; int main() { bar(S()); // ERROR HERE: 'bar' is ambiguous } Here, has_foo<S, void(S::*)()>::value is true, so enable_if<false> gets instantiated; enable_if<false>::type produces a substitution error, and therefore the second overload of bar() should be removed from the overload resolution set.
Fixed together with bug 299911.