This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-04-18


1892. Use of auto in function type

Section: 9.2.9.7  [dcl.spec.auto]     Status: CD4     Submitter: Richard Smith     Date: 2014-03-12

[Moved to DR at the November, 2014 meeting.]

There appear to be no restrictions against using the auto specifier in examples like the following:

  template<typename T> using X = T;
  X<auto()> f_with_deduced_return_type; // ok
  std::vector<auto(*)()> v; // ok?!
  void f(auto (*)()); // ok?!

Proposed resolution (June, 2014):

Change 9.2.9.7 [dcl.spec.auto] paragraph 2 as follows:

The placeholder type can appear with a function declarator in the decl-specifier-seq, type-specifier-seq, conversion-function-id, or trailing-return-type, in any context where such a declarator is valid. If the function declarator includes a trailing-return-type (9.3.4.6 [dcl.fct]), that specifies the declared return type of the function. Otherwise, the function declarator shall declare a function. If the declared return type of the function contains a placeholder type, the return type of the function is deduced from return statements in the body of the function, if any.