This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 112c. See for the official list.


1674. Return type deduction for address of function

Section:  []     Status: C++14     Submitter: Richard Smith     Date: 2013-05-02

[Applied to WP at the February, 2014 meeting.]

The following example appears in [] 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 [temp.deduct.funcaddr]:

A placeholder type ( []) 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.