Consider the following program:
#include <type_traits> enum class dummy {}; template <typename T> using EnableIf = typename std::enable_if<T::value, dummy>::type; template <typename T> using DisableIf = typename std::enable_if<!T::value, dummy>::type; template <typename T> struct dependent_true_type : std::true_type {}; template <typename T, EnableIf<dependent_true_type<T>>...> std::true_type f(); template <typename T, DisableIf<dependent_true_type<T>>...> std::false_type f(); static_assert(decltype(f<int>())::value, ""); int main() {}
GCC 4.7 glady accepts this program. My recent clang 3.1 build claims that the call to f
ambiguous.
test.c++:22:24: fatal error: call to 'f' is ambiguous static_assert(decltype(f<int>())::value, ""); ^~~~~~ test.c++:17:16: note: candidate function [with T = int, $1 = <>] std::true_type f(); ^ test.c++:20:17: note: candidate function [with T = int, $1 = <>] std::false_type f(); ^ 1 error generated.
It accepts the program if I write f<int, dummy{}>()
.
It seems that clang does not consider the type of the parameter package when the package is empty, which means that it does not remove it from the candidate set. GCC seems to perform the substitution by type of parameter package, even if the package is empty, and since the replacement mentioned is not performed for a single overload, there is no ambiguity.
Which of the two are correct?
source share