Skip to content

Commit 55508ed

Browse files
jensmaurertkoeppe
authored andcommitted
P0609R3 Attributes for Structured Bindings
1 parent fe11b0a commit 55508ed

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
@@ -6950,8 +6966,11 @@
69506966
A structured binding declaration introduces the \grammarterm{identifier}{s}
69516967
$\tcode{v}_0$, $\tcode{v}_1$, $\tcode{v}_2, \dotsc$
69526968
of the
6953-
\grammarterm{identifier-list} as names
6969+
\grammarterm{attributed-identifier-list} as names
69546970
of \defn{structured binding}{s}.
6971+
The optional \grammarterm{attribute-specifier-seq} of
6972+
an \grammarterm{attributed-identifier}
6973+
appertains to the structured binding so introduced.
69556974
Let \cv{} denote the \grammarterm{cv-qualifier}{s} in
69566975
the \grammarterm{decl-specifier-seq} and
69576976
\placeholder{S} consist of the \grammarterm{storage-class-specifier}{s} of
@@ -6990,7 +7009,7 @@
69907009

69917010
\pnum
69927011
If \tcode{E} is an array type with element type \tcode{T}, the number
6993-
of elements in the \grammarterm{identifier-list} shall be equal to the
7012+
of elements in the \grammarterm{attributed-identifier-list} shall be equal to the
69947013
number of elements of \tcode{E}. Each $\tcode{v}_i$ is the name of an
69957014
lvalue that refers to the element $i$ of the array and whose type
69967015
is \tcode{T}; the referenced type is \tcode{T}.
@@ -7013,7 +7032,7 @@
70137032
shall be a well-formed integral constant expression
70147033
and
70157034
the number of elements in
7016-
the \grammarterm{identifier-list} shall be equal to the value of that
7035+
the \grammarterm{attributed-identifier-list} shall be equal to the value of that
70177036
expression.
70187037
Let \tcode{i} be an index prvalue of type \tcode{std::size_t}
70197038
corresponding to $\tcode{v}_i$.
@@ -7055,7 +7074,7 @@
70557074
well-formed when named as \tcode{\exposidnc{e}.\placeholder{name}}
70567075
in the context of the structured binding,
70577076
\tcode{E} shall not have an anonymous union member, and
7058-
the number of elements in the \grammarterm{identifier-list} shall be
7077+
the number of elements in the \grammarterm{attributed-identifier-list} shall be
70597078
equal to the number of non-static data members of \tcode{E}.
70607079
Designating the non-static data members of \tcode{E} as
70617080
$\tcode{m}_0$, $\tcode{m}_1$, $\tcode{m}_2, \dotsc$
@@ -9228,6 +9247,7 @@
92289247
The attribute may be applied to the declaration of a class,
92299248
\grammarterm{typedef-name},
92309249
variable (including a structured binding declaration),
9250+
structured binding,
92319251
non-static data member,
92329252
function,
92339253
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)