This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-12-20
[Moved to DR at the November, 2016 meeting.]
The resolution ofissue 692 (found indocument N3281) made the following example ambiguous and thusill-formed:
template<class T> void print(ostream &os, const T &t) { os << t; } template <class T, class... Args> void print(ostream &os, const T &t, const Args&... rest) { os << t << ", "; print(os, rest...); } int main() { print(cout, 42); print(cout, 42, 1.23); }This pattern seems fairly intuitive; is it reason to reconsider ormodify the outcome ofissue 692?
(See alsoissue 1432.)
Notes from the October, 2012 meeting:
CWG agreed that the example should be accepted, handling this caseas a late tiebreaker, preferring an omitted parameter over a parameterpack.
Additional note (March, 2013):
For another example:
template<typename ...T> int f(T*...) { return 1; } template<typename T> int f(const T&) { return 2; } int main() { if (f((int*)0) != 1) { return 1; } return 0; }This worked as expected prior to the resolution ofissue 692.
Proposed resolution (June, 2016):
Change 13.10.3.5 [temp.deduct.partial] paragraph 8 asfollows:
IfA was transformed from a function parameter packandP is not a parameter pack, type deduction fails. Otherwise,usingUsing the resulting typesP andA,the deduction is then done as described in13.10.3.6 [temp.deduct.type]. IfP is a function parameter pack,the typeA of each remaining parameter type of the argumenttemplate is compared with the typeP of thedeclarator-idof the function parameter pack. Each comparison deduces template argumentsfor subsequent positions in the template parameter packs expanded by thefunction parameter pack.Similarly, ifA was transformed from afunction parameter pack, it is compared with each remaining parameter typeof the parameter template. If deduction succeeds for a given type,the type from the argument template is considered to be at least asspecialized as the type from the parameter template. [Example:...
Add the following as a new paragraph following13.10.3.5 [temp.deduct.partial] paragraph 10:
Function templateF is at least as specialized as functiontemplateG if, for each pair of types used to determine theordering, the type fromF is at least as specialized as the typefromG.F is more specialized thanGifF is at least as specialized asG andG isnot at least as specialized asF.
If, after considering the above, function templateF is atleast as specialized as function templateG and vice-versa, and ifG has a trailing paramter pack for whichF does not have acorresponding parameter, and ifF does not have a trailingparameter pack, thenF is more specializedthanG.
This resolution also resolvesissue 1825.