N4527 14.8.2.4 [temp.deduct.partial]
3 The types used to determine the ordering depend on the context in which the partial ordering is done:
(3.1) — In the context of a function call, the types used are those function parameter types for which the function call has arguments.
(3.2) — In the context of a call to a conversion function, the return types of the conversion function templates are used.
(3.3) — In other contexts (14.5.6.2) the function template’s function type is used.
4 Each type nominated above from the parameter template and the corresponding type from the argument template are used as the types of
P
andA
.8 If
A
was transformed from a function parameter pack andP
is not a parameter pack, type deduction fails. Otherwise, using the resulting typesP
andA
, the deduction is then done as described in 14.8.2.5. IfP
is a function parameter pack, the typeA
of each remaining parameter type of the argument template is compared with the typeP
of the declarator-id of the function parameter pack. Each comparison deduces template arguments for subsequent positions in the template parameter packs expanded by the function parameter pack. If deduction succeeds for a given type, the type from the argument template is considered to be at least as specialized as the type from the parameter template. [ Example:
template<class... Args> void f(Args... args); // #1
template<class T1, class... Args> void f(T1 a1, Args... args); // #2
template<class T1, class T2> void f(T1 a1, T2 a2); // #3
f(); // calls #1
f(1, 2, 3); // calls #2
f(1, 2); // calls #3; non-variadic template #3 is more
// specialized than the variadic templates #1 and #2
Why f(1, 2, 3);
calls #2?
I need more details including:
1 Which context is it?
2 What are the transformed froms?
e.g. the transformed from of #1 is void (U)
, void (U...)
or other form?(U
means an unique type)
14.5.6.2 [temp.func.order]/p3
To produce the transformed template, for each type, non-type, or template template parameter (including template parameter packs (14.5.3) thereof) synthesize a unique type, value, or class template respectively and substitute it for each occurrence of that parameter in the function type of the template.
3 What are the types of P
and A
used in deduction? e.g
template <class T> void f(T);
int a = 1;
f(a);//P = T, A = int