Created on 2013-05-02.00:00:00 last changed 122 months ago
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.
[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)
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-11-24 00:00:00 | admin | set | status: accepted -> c++14 |
2014-03-03 00:00:00 | admin | set | status: tentatively ready -> accepted |
2014-01-20 00:00:00 | admin | set | messages: + msg4728 |
2014-01-20 00:00:00 | admin | set | status: drafting -> tentatively ready |
2013-10-14 00:00:00 | admin | set | status: open -> drafting |
2013-05-02 00:00:00 | admin | create |