Skip to content

P0609R3 Attributes for Structured Bindings #6891

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions source/declarations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,27 @@
\keyword{using} identifier \opt{attribute-specifier-seq} \terminal{=} defining-type-id \terminal{;}
\end{bnf}

\begin{bnf}
\nontermdef{attributed-identifier}\br
identifier \opt{attribute-specifier-seq}
\end{bnf}

\begin{bnf}
\nontermdef{attributed-identifier-list}\br
attributed-identifier\br
attributed-identifier-list \terminal{,} attributed-identifier
\end{bnf}

\begin{bnf}
\nontermdef{structured-binding-declaration}\br
\opt{attribute-specifier-seq} decl-specifier-seq \opt{ref-qualifier} \terminal{[} attributed-identifier-list \terminal{]}
\end{bnf}

\begin{bnf}
\nontermdef{simple-declaration}\br
decl-specifier-seq \opt{init-declarator-list} \terminal{;}\br
attribute-specifier-seq decl-specifier-seq init-declarator-list \terminal{;}\br
\opt{attribute-specifier-seq} decl-specifier-seq \opt{ref-qualifier} \terminal{[} identifier-list \terminal{]} initializer \terminal{;}
structured-binding-declaration initializer \terminal{;}
\end{bnf}

\begin{bnf}
Expand Down Expand Up @@ -186,7 +202,7 @@
\end{example}

\pnum
A \grammarterm{simple-declaration} with an \grammarterm{identifier-list} is called
A \grammarterm{simple-declaration} with a \grammarterm{structured-binding-declaration} is called
a \defn{structured binding declaration}\iref{dcl.struct.bind}.
Each \grammarterm{decl-specifier} in the \grammarterm{decl-specifier-seq}
shall be
Expand Down Expand Up @@ -6968,8 +6984,11 @@
A structured binding declaration introduces the \grammarterm{identifier}{s}
$\tcode{v}_0$, $\tcode{v}_1$, $\tcode{v}_2, \dotsc$
of the
\grammarterm{identifier-list} as names
\grammarterm{attributed-identifier-list} as names
of \defn{structured binding}{s}.
The optional \grammarterm{attribute-specifier-seq} of
an \grammarterm{attributed-identifier}
appertains to the structured binding so introduced.
Let \cv{} denote the \grammarterm{cv-qualifier}{s} in
the \grammarterm{decl-specifier-seq} and
\placeholder{S} consist of the \grammarterm{storage-class-specifier}{s} of
Expand Down Expand Up @@ -7008,7 +7027,7 @@

\pnum
If \tcode{E} is an array type with element type \tcode{T}, the number
of elements in the \grammarterm{identifier-list} shall be equal to the
of elements in the \grammarterm{attributed-identifier-list} shall be equal to the
number of elements of \tcode{E}. Each $\tcode{v}_i$ is the name of an
lvalue that refers to the element $i$ of the array and whose type
is \tcode{T}; the referenced type is \tcode{T}.
Expand All @@ -7031,7 +7050,7 @@
shall be a well-formed integral constant expression
and
the number of elements in
the \grammarterm{identifier-list} shall be equal to the value of that
the \grammarterm{attributed-identifier-list} shall be equal to the value of that
expression.
Let \tcode{i} be an index prvalue of type \tcode{std::size_t}
corresponding to $\tcode{v}_i$.
Expand Down Expand Up @@ -7073,7 +7092,7 @@
well-formed when named as \tcode{\exposidnc{e}.\placeholder{name}}
in the context of the structured binding,
\tcode{E} shall not have an anonymous union member, and
the number of elements in the \grammarterm{identifier-list} shall be
the number of elements in the \grammarterm{attributed-identifier-list} shall be
equal to the number of non-static data members of \tcode{E}.
Designating the non-static data members of \tcode{E} as
$\tcode{m}_0$, $\tcode{m}_1$, $\tcode{m}_2, \dotsc$
Expand Down Expand Up @@ -9246,6 +9265,7 @@
The attribute may be applied to the declaration of a class,
\grammarterm{typedef-name},
variable (including a structured binding declaration),
structured binding,
non-static data member,
function,
enumeration, or
Expand Down
2 changes: 1 addition & 1 deletion source/preprocessor.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@
\defnxname{cpp_sized_deallocation} & \tcode{201309L} \\ \rowsep
\defnxname{cpp_static_assert} & \tcode{202306L} \\ \rowsep
\defnxname{cpp_static_call_operator} & \tcode{202207L} \\ \rowsep
\defnxname{cpp_structured_bindings} & \tcode{201606L} \\ \rowsep
\defnxname{cpp_structured_bindings} & \tcode{202403L} \\ \rowsep
\defnxname{cpp_template_template_args} & \tcode{201611L} \\ \rowsep
\defnxname{cpp_threadsafe_static_init} & \tcode{200806L} \\ \rowsep
\defnxname{cpp_unicode_characters} & \tcode{200704L} \\ \rowsep
Expand Down
2 changes: 1 addition & 1 deletion source/statements.tex
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@
\begin{bnf}
\nontermdef{for-range-declaration}\br
\opt{attribute-specifier-seq} decl-specifier-seq declarator\br
\opt{attribute-specifier-seq} decl-specifier-seq \opt{ref-qualifier} \terminal{[} identifier-list \terminal{]}
structured-binding-declaration
\end{bnf}

\begin{bnf}
Expand Down