Skip to content

Commit 8a574e6

Browse files
committed
CWG2867 Order of initialization for structured bindings
1 parent e902ec5 commit 8a574e6

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

source/basic.tex

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4500,7 +4500,7 @@
45004500
\pnum
45014501
\indextext{initializer!temporary and declarator}%
45024502
\indextext{temporary!order of destruction of}%
4503-
There are four contexts in which temporaries are destroyed at a different
4503+
There are five contexts in which temporaries are destroyed at a different
45044504
point than the end of the full-expression.
45054505
The first context is when a default constructor is called to initialize
45064506
an element of an array with no corresponding initializer\iref{dcl.init}.
@@ -4626,6 +4626,14 @@
46264626
the object persists for the lifetime of the reference
46274627
initialized by the \grammarterm{for-range-initializer}.
46284628

4629+
\pnum
4630+
The fifth context is when a temporary object
4631+
is created in a structured binding declaration\iref{dcl.struct.bind}.
4632+
Any temporary objects introduced by
4633+
the \grammarterm{initializer}{s} for the variables
4634+
with unique names
4635+
are destroyed at the end of the structured binding declaration.
4636+
46294637
\pnum
46304638
Let \tcode{x} and \tcode{y} each be either
46314639
a temporary object whose lifetime is not extended, or
@@ -5911,7 +5919,8 @@
59115919
\item
59125920
an immediate invocation\iref{expr.const},
59135921
\item
5914-
an \grammarterm{init-declarator}\iref{dcl.decl} or
5922+
an \grammarterm{init-declarator}\iref{dcl.decl}
5923+
(including such introduced by a structured binding\iref{dcl.struct.bind}) or
59155924
a \grammarterm{mem-initializer}\iref{class.base.init},
59165925
including the constituent expressions of the initializer,
59175926
\item

source/declarations.tex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7099,6 +7099,10 @@
70997099
Each $\tcode{v}_i$ is the name of an lvalue of type $\tcode{T}_i$
71007100
that refers to the object bound to $\tcode{r}_i$;
71017101
the referenced type is $\tcode{T}_i$.
7102+
The initialization of \exposid{e} is
7103+
sequenced before the initialization of any $\tcode{r}_i$.
7104+
The initialization of each $\tcode{r}_i$ is
7105+
sequenced before the initialization of any $\tcode{r}_j$ where $i \le j$.
71027106

71037107
\pnum
71047108
Otherwise,

0 commit comments

Comments
 (0)