Skip to content

Commit 56c4cb9

Browse files
authored
Merge 2024-03 CWG Motion 4
P0609R3 Attributes for Structured Bindings
2 parents 09db8d5 + 41efe54 commit 56c4cb9

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

source/declarations.tex

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,27 @@
6767
\keyword{using} identifier \opt{attribute-specifier-seq} \terminal{=} defining-type-id \terminal{;}
6868
\end{bnf}
6969

70+
\begin{bnf}
71+
\nontermdef{attributed-identifier}\br
72+
identifier \opt{attribute-specifier-seq}
73+
\end{bnf}
74+
75+
\begin{bnf}
76+
\nontermdef{attributed-identifier-list}\br
77+
attributed-identifier\br
78+
attributed-identifier-list \terminal{,} attributed-identifier
79+
\end{bnf}
80+
81+
\begin{bnf}
82+
\nontermdef{structured-binding-declaration}\br
83+
\opt{attribute-specifier-seq} decl-specifier-seq \opt{ref-qualifier} \terminal{[} attributed-identifier-list \terminal{]}
84+
\end{bnf}
85+
7086
\begin{bnf}
7187
\nontermdef{simple-declaration}\br
7288
decl-specifier-seq \opt{init-declarator-list} \terminal{;}\br
7389
attribute-specifier-seq decl-specifier-seq init-declarator-list \terminal{;}\br
74-
\opt{attribute-specifier-seq} decl-specifier-seq \opt{ref-qualifier} \terminal{[} identifier-list \terminal{]} initializer \terminal{;}
90+
structured-binding-declaration initializer \terminal{;}
7591
\end{bnf}
7692

7793
\begin{bnf}
@@ -186,7 +202,7 @@
186202
\end{example}
187203

188204
\pnum
189-
A \grammarterm{simple-declaration} with an \grammarterm{identifier-list} is called
205+
A \grammarterm{simple-declaration} with a \grammarterm{structured-binding-declaration} is called
190206
a \defn{structured binding declaration}\iref{dcl.struct.bind}.
191207
Each \grammarterm{decl-specifier} in the \grammarterm{decl-specifier-seq}
192208
shall be
@@ -6968,8 +6984,11 @@
69686984
A structured binding declaration introduces the \grammarterm{identifier}{s}
69696985
$\tcode{v}_0$, $\tcode{v}_1$, $\tcode{v}_2, \dotsc$
69706986
of the
6971-
\grammarterm{identifier-list} as names
6987+
\grammarterm{attributed-identifier-list} as names
69726988
of \defn{structured binding}{s}.
6989+
The optional \grammarterm{attribute-specifier-seq} of
6990+
an \grammarterm{attributed-identifier}
6991+
appertains to the structured binding so introduced.
69736992
Let \cv{} denote the \grammarterm{cv-qualifier}{s} in
69746993
the \grammarterm{decl-specifier-seq} and
69756994
\placeholder{S} consist of the \grammarterm{storage-class-specifier}{s} of
@@ -7008,7 +7027,7 @@
70087027

70097028
\pnum
70107029
If \tcode{E} is an array type with element type \tcode{T}, the number
7011-
of elements in the \grammarterm{identifier-list} shall be equal to the
7030+
of elements in the \grammarterm{attributed-identifier-list} shall be equal to the
70127031
number of elements of \tcode{E}. Each $\tcode{v}_i$ is the name of an
70137032
lvalue that refers to the element $i$ of the array and whose type
70147033
is \tcode{T}; the referenced type is \tcode{T}.
@@ -7031,7 +7050,7 @@
70317050
shall be a well-formed integral constant expression
70327051
and
70337052
the number of elements in
7034-
the \grammarterm{identifier-list} shall be equal to the value of that
7053+
the \grammarterm{attributed-identifier-list} shall be equal to the value of that
70357054
expression.
70367055
Let \tcode{i} be an index prvalue of type \tcode{std::size_t}
70377056
corresponding to $\tcode{v}_i$.
@@ -7073,7 +7092,7 @@
70737092
well-formed when named as \tcode{\exposidnc{e}.\placeholder{name}}
70747093
in the context of the structured binding,
70757094
\tcode{E} shall not have an anonymous union member, and
7076-
the number of elements in the \grammarterm{identifier-list} shall be
7095+
the number of elements in the \grammarterm{attributed-identifier-list} shall be
70777096
equal to the number of non-static data members of \tcode{E}.
70787097
Designating the non-static data members of \tcode{E} as
70797098
$\tcode{m}_0$, $\tcode{m}_1$, $\tcode{m}_2, \dotsc$
@@ -9246,6 +9265,7 @@
92469265
The attribute may be applied to the declaration of a class,
92479266
\grammarterm{typedef-name},
92489267
variable (including a structured binding declaration),
9268+
structured binding,
92499269
non-static data member,
92509270
function,
92519271
enumeration, or

source/preprocessor.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1868,7 +1868,7 @@
18681868
\defnxname{cpp_sized_deallocation} & \tcode{201309L} \\ \rowsep
18691869
\defnxname{cpp_static_assert} & \tcode{202306L} \\ \rowsep
18701870
\defnxname{cpp_static_call_operator} & \tcode{202207L} \\ \rowsep
1871-
\defnxname{cpp_structured_bindings} & \tcode{201606L} \\ \rowsep
1871+
\defnxname{cpp_structured_bindings} & \tcode{202403L} \\ \rowsep
18721872
\defnxname{cpp_template_template_args} & \tcode{201611L} \\ \rowsep
18731873
\defnxname{cpp_threadsafe_static_init} & \tcode{200806L} \\ \rowsep
18741874
\defnxname{cpp_unicode_characters} & \tcode{200704L} \\ \rowsep

source/statements.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@
509509
\begin{bnf}
510510
\nontermdef{for-range-declaration}\br
511511
\opt{attribute-specifier-seq} decl-specifier-seq declarator\br
512-
\opt{attribute-specifier-seq} decl-specifier-seq \opt{ref-qualifier} \terminal{[} identifier-list \terminal{]}
512+
structured-binding-declaration
513513
\end{bnf}
514514

515515
\begin{bnf}

0 commit comments

Comments
 (0)