Skip to content

Commit f7ee4d7

Browse files
burblebeetkoeppe
authored andcommitted
CWG2867 Order of initialization for structured bindings
1 parent 3ca9529 commit f7ee4d7

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
@@ -4495,7 +4495,7 @@
44954495
\pnum
44964496
\indextext{initializer!temporary and declarator}%
44974497
\indextext{temporary!order of destruction of}%
4498-
There are four contexts in which temporaries are destroyed at a different
4498+
There are five contexts in which temporaries are destroyed at a different
44994499
point than the end of the full-expression.
45004500
The first context is when a default constructor is called to initialize
45014501
an element of an array with no corresponding initializer\iref{dcl.init}.
@@ -4621,6 +4621,14 @@
46214621
the object persists for the lifetime of the reference
46224622
initialized by the \grammarterm{for-range-initializer}.
46234623

4624+
\pnum
4625+
The fifth context is when a temporary object
4626+
is created in a structured binding declaration\iref{dcl.struct.bind}.
4627+
Any temporary objects introduced by
4628+
the \grammarterm{initializer}{s} for the variables
4629+
with unique names
4630+
are destroyed at the end of the structured binding declaration.
4631+
46244632
\pnum
46254633
Let \tcode{x} and \tcode{y} each be either
46264634
a temporary object whose lifetime is not extended, or
@@ -5906,7 +5914,8 @@
59065914
\item
59075915
an immediate invocation\iref{expr.const},
59085916
\item
5909-
an \grammarterm{init-declarator}\iref{dcl.decl} or
5917+
an \grammarterm{init-declarator}\iref{dcl.decl}
5918+
(including such introduced by a structured binding\iref{dcl.struct.bind}) or
59105919
a \grammarterm{mem-initializer}\iref{class.base.init},
59115920
including the constituent expressions of the initializer,
59125921
\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 < j$.
71027106

71037107
\pnum
71047108
Otherwise,

0 commit comments

Comments
 (0)