CWG Issue 2376 (original) (raw)

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

2025-04-13


2376. Class template argument deduction with array declarator

Section: 12.2.2.9 [over.match.class.deduct]Status: CD5Submitter: Mike MillerDate: 2018-03-01

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

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).

Proposed resolution, March, 2019:

Change 9.2.9.8 [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.5 [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_] Theplaceholder 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.