#include <iostream>
template<typename T>
class A
{
};
template <typename T, typename T2, typename...Ts, typename = void >
//^remove this compiles
void func(T &&expr, T2 &&case1, Ts &&... args)
{
std::cout << "General\n";
}
template <typename T, typename A_Type, typename...Ts, typename = void>
//^remove this compiles
auto func(T &&expr, A<A_Type>&&, Ts &&... args)
{
std::cout << "A<Type>\n";
}
int main()
{
func(1, A<int>{}, 2); //ambiguous call
}
GCC 10.1 and older gives a ambiguous call error, but it compiles with 10.2. Demo here. I wonder if it's a bug on older version of GCC or my code is wrong and shouldn't compile.
The anonymous typename is for some SFINAE stuff, and I want a workaround to make it compile on older version of GCC.