A C++ function can have more than one parameter packs. Although it does not look very practical thing, it is still interesting to know language rules about them.
For example, in case of two overloads:
constexpr int f(auto...) { return 1; }
constexpr int f(auto..., auto...) { return 2; }
Calling f
with no arguments f()
selects version 1 in MSVC, version 2 in Clang, and ambiguous overloaded call
in GCC.
If call f
with an argument f(1)
, then both MSVC and GCC select version 1, while Clang still selects version 2.
Demo: https://gcc.godbolt.org/z/PWr6h1dn1
Which compiler is right here?
There is a similar question Function template overload resolution with two parameter packs, but
- the functions there have only one parameter pack as function argument (and the second parameter pack is simply unused),
- the example there results in ambiguity error in all tested compilers (however mentioned compiler bugs are still not resolved). Actually an ambiguity is what one could expect in this example as well, but here most compilers select one of the overloads without an error.