[temp.arg.explicit]/3 of the C++17 standard (final draft) says about deduction of function template arguments with explicitly specified template argument lists:
In contexts where deduction is done and fails, or [...], if a template argument list is specified and it, along with any default template arguments, identifies a single function template specialization, then the template-id is an lvalue for the function template specialization.
How does this apply to parameter packs?
Consider
template<typename...>
struct S {
S(int) {}
};
template<typename... A>
void f(S<A...>) {}
int main() {
f<int>(0);
}
This compiles on MSVC, but not on GCC and Clang, see godbolt. It would also be my intuition that it should fail, because deduction will fail, but the quote above seems to imply that even if deduction fails, since f<int>
(in my understanding) identifies uniquely a template specialization, f<int>
should be considered to refer to that specialization and then call it, without overload resolution, which will work, implicitly converting 0
to S<int>
.
What is wrong in my understanding of the quote or is MSVC indeed correct?
Note that if we try to call f<>(0);
(which I guess should work by the considerations above) all three compilers refuse to compile.