I was using parameter pack when I noticed that one such case(shown below) compiles fine in gcc and clang but not in msvc:
template<class T> void func(T a, T b= T{})
{
}
template<class T, class... S> void func(T a, S... b)
{
}
int main()
{
func(1); // Should this call succeed?
}
Here is the link for verifying the same: https://godbolt.org/z/8KsrcnMez
As can be seen the above program fails in msvc with the error message:
<source>(13): error C2668: 'func': ambiguous call to overloaded function
<source>(6): note: could be 'void func<int,>(T)'
with
[
T=int
]
<source>(2): note: or 'void func<int>(T,T)'
with
[
T=int
]
<source>(13): note: while trying to match the argument list '(int)'
But the same compiles fine with gcc and clang.
Which compiler(s) is right here?