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


1674. Return type deduction for address of function

Section: 9.2.9.7  [dcl.spec.auto]     Status: C++14     Submitter: Richard Smith     Date: 2013-05-02

[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:

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.