This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-11-11
Consider:
template <class T> T f(T); // #1 template <class T> T* f(T*); // #2 auto p = &f<int>;
Accoring to 12.3 [over.over] paragraph 3 and 12.3 [over.over] paragraph 5:
The specialization, if any, generated by template argument deduction (13.10.4 [temp.over], 13.10.3.3 [temp.deduct.funcaddr], 13.10.2 [temp.arg.explicit]) for each function template named is added to the set of selected functions considered.
[...]Any given function template specialization F1 is eliminated if the set contains a second function template specialization whose function template is more specialized than the function template of F1 according to the partial ordering rules of 13.7.7.3 [temp.func.order]. After such eliminations, if any, there shall remain exactly one selected function.
Major implementations reject the example as ambiguous, yet the wording specifies to unambiguously choose #2.
Suggested resolution [SUPERSEDED]:
Change in 12.3 [over.over] paragraph 5 as follows:
Any given function template specialization F1 is eliminated if the set contains a second function template specialization whose function template ismore specializedbetter than the function template of F1. If there is no target, a function template is better than another if it is more constrained than the other; otherwise a function template is better than another if it is more specialized than the other according to the partial ordering rules of 13.7.7.3 [temp.func.order]. After such eliminations, if any, there shall remain exactly one selected function.
Proposed resolution:
Change in 12.3 [over.over] paragraph 5 as follows:
AnyIf there is a target, any given function template specialization F1 is eliminated if the set contains a second function template specialization whose function template is more specialized than the function template of F1 according to the partial ordering rules of 13.7.7.3 [temp.func.order]. After such eliminations, if any, there shall remain exactly one selected function.
Additional notes (July, 2024)
The example in this issue is resolved by issue 2918 by suitably ordering placeholder type deduction before the address operation.