Title
Class template argument deduction with array declarator
Status
cd5
Section
12.2.2.9 [over.match.class.deduct]
Submitter
Mike Miller

Created on 2018-03-01.00:00:00 last changed 7 months ago

Messages

Date: 2020-12-15.00:00:00

Proposed resolution, March, 2019:

Change 9.2.9.7 [dcl.type.class.deduct] paragraph 1 as follows:

If a placeholder for a deduced class type appears as a decl-specifier in the decl-specifier-seq of an initializing declaration (9.4 [dcl.init]) of a variable, the declared type of the variable shall be cv T, where T is the placeholder. [Example:

  template <class ...T> struct A {
    A(T...) {}
  };
  A x[29]{};    // error: no declarator operators allowed
  const A& y{}; // error: no declarator operators allowed

end example] The placeholder is replaced by the return type of the function selected by overload resolution for class template deduction (12.2.2.9 [over.match.class.deduct]). If the decl-specifier-seq is followed by an init-declarator-list or member-declarator-list containing more than one declarator, the type that replaces the placeholder shall be the same in each deduction.

Date: 2018-11-15.00:00:00

Notes from the November, 2018 meeting:

The example is intended to be ill-formed; the intent is that declarator operators are not permitted, as with decltype(auto).

Date: 2019-07-15.00:00:00

[Accepted as a DR at the July, 2019 meeting.]

An example like

   template <class ...T> struct A {
     A(T...) {}
   };
   A x[29]{};

Appears to be permitted by the current wording of the Standard, but existing implementations reject it. Should this usage be supported (in which case some mention of it in the wording would be useful) or prohibited?

History
Date User Action Args
2020-12-15 00:00:00adminsetmessages: + msg6412
2020-12-15 00:00:00adminsetmessages: + msg6411
2018-03-01 00:00:00admincreate