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
[Applied to WP at the February, 2014 meeting.]
The following example appears in 9.2.9.7 [dcl.spec.auto] paragraph 12:
template <class T> auto f(T t) { return t; } // return type deduced at instantiation time typedef decltype(f(1)) fint_t; // instantiates f<int> to deduce return type template<class T> auto f(T* t) { return *t; } void g() { int (*p)(int*) = &f; } // instantiates both fs to determine return types, // chooses second
This is the desired behavior, but the current wording does not achieve that effect. One possible way this could work would be:
auto is treated as a non-deduced context
in 13.10.3.3 [temp.deduct.funcaddr], the deduced A is produced by substituting the deduced template arguments into the original function template, rather than substituting them into P, and the deduced A is the type of the produced function declaration (triggering instantiation of a definition as needed to complete the type)
Proposed resolution (November, 2013):
Add the following as a new paragraph at the end of 13.10.3.3 [temp.deduct.funcaddr]:
A placeholder type (9.2.9.7 [dcl.spec.auto]) in the return type of a function template is a non-deduced context. If template argument deduction succeeds for such a function, the return type is determined from instantiation of the function body.