Title
Structured bindings and array cv-qualifiers
Status
dr
Section
9.6 [dcl.struct.bind]
Submitter
Barry Revzin

Created on 2018-12-11.00:00:00 last changed 5 months ago

Messages

Date: 2021-12-15.00:00:00

Proposed resolution (December, 2021):

Change 9.6 [dcl.struct.bind] paragraph 1 as follows:

If the assignment-expression in the initializer has array type cv1 A and no ref-qualifier is present, e is defined by...

Date: 2022-02-15.00:00:00

[Accepted at the February, 2022 meeting.]

According to 9.6 [dcl.struct.bind] paragraph 1,

A structured binding declaration introduces the identifiers v0, v1, v2, ... of the identifier-list as names of structured bindings. Let cv denote the cv-qualifiers in the decl-specifier-seq and S consist of the storage-class-specifiers of the decl-specifier-seq (if any). A cv that includes volatile is deprecated; see D.5 [depr.volatile.type]. First, a variable with a unique name e is introduced. If the assignment-expression in the initializer has array type A and no ref-qualifier is present, e is defined by

    attribute-specifier-seqopt S cv A e ;

and each element is copy-initialized or direct-initialized from the corresponding element of the assignment-expression as specified by the form of the initializer.

This means that in an example like

  const int arr[1]{};
  auto [i] = arr;

i is a reference to const int. Presumably the fact that the array is copied should drop the array's cv-qualification.

History
Date User Action Args
2022-02-15 00:00:00adminsetstatus: ready -> dr
2022-01-06 00:00:00adminsetmessages: + msg6599
2018-12-11 00:00:00admincreate