Title
decltype(auto) with parenthesized initializer
Status
cd4
Section
9.2.9.7 [dcl.spec.auto]
Submitter
Vinny Romano

Created on 2014-06-30.00:00:00 last changed 94 months ago

Messages

Date: 2015-05-15.00:00:00

[Moved to DR at the May, 2015 meeting.]

Date: 2015-04-15.00:00:00

Proposed resolution (April, 2015):

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

...If the placeholder is the decltype(auto) type-specifier, the declared type of the variable or return type of the function shall be the placeholder alone. The type deduced for the variable or return type is determined as described in 9.2.9.3 [dcl.type.simple], as though the initializer initializer-clause or expression-list of the initializer or the expression of the return statement had been the operand of the decltype. [Example:
  int i;
  int&& f();
  auto           x2a(i);    // decltype(x2a) is int
  decltype(auto) x2d(i);    // decltype(x2d) is int
  auto           x3a = i;   // decltype(x3a) is int
  decltype(auto) x3d = i;   // decltype(x3d) is int
  ...
Date: 2014-06-30.00:00:00

According to 9.2.9.7 [dcl.spec.auto] paragraph 7,

If the placeholder is the decltype(auto) type-specifier, the declared type of the variable or return type of the function shall be the placeholder alone. The type deduced for the variable or return type is determined as described in 9.2.9.3 [dcl.type.simple], as though the initializer had been the operand of the decltype.

This is problematic when the parenthesized form of initializer is used, e.g.,

  int i;
  decltype(auto) x(i);

the specification would deduce the type as decltype((i)), or int&. The wording should be clarified that the expression and not the entire initializer is considered to be the operand of decltype.

History
Date User Action Args
2017-02-06 00:00:00adminsetstatus: drwp -> cd4
2015-11-10 00:00:00adminsetstatus: dr -> drwp
2015-05-25 00:00:00adminsetmessages: + msg6051
2015-05-25 00:00:00adminsetstatus: tentatively ready -> dr
2015-04-13 00:00:00adminsetmessages: + msg5313
2015-04-13 00:00:00adminsetstatus: drafting -> tentatively ready
2014-06-30 00:00:00admincreate