The following code fails to compile both on g++ and clang++ with different error messages. In particular, it is the second line of main which triggers an error.
I do not understand why, as there is nothing ambiguous. The function has two arguments, which means that the template pack must have exactly two arguments, and all types are duly explicitly specified.
Any explanation?
#include <iostream>
enum A {A1,A2};
template <typename...Ts, A a=A2>
void foo(Ts...ps) { (std::cout << ... << ps); }
int main()
{
foo<int,int>(1,2); // this compiles
foo<int,int,A2>(1,2); // this does not compile
return 0;
}