Skip to content

Commit 48ec7be

Browse files
committed
[basic.life] Reference [intro.object] in transparent replacement note and improve example
1 parent a470ff8 commit 48ec7be

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

source/basic.tex

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3660,6 +3660,13 @@
36603660
lifetime of the new object has started, can be used to manipulate the new
36613661
object.
36623662

3663+
\begin{note}
3664+
Additionally, if the requirements in \ref{intro.object}
3665+
for the creation of subobjects are met,
3666+
once the lifetime of the new object has started,
3667+
the containing object of the original object
3668+
can be used to manipulate the new object.
3669+
\end{note}
36633670
\begin{example}
36643671
\begin{codeblock}
36653672
struct C {
@@ -3677,10 +3684,14 @@
36773684
return *this;
36783685
}
36793686

3680-
C c1;
3681-
C c2;
3682-
c1 = c2; // well-defined
3683-
c1.f(); // well-defined; \tcode{c1} refers to a new object of type \tcode{C}
3687+
void g() {
3688+
C c1;
3689+
C c2;
3690+
c1 = c2; // well-defined
3691+
c1.f(); // well-defined; \tcode{c1} refers to a new object of type \tcode{C}
3692+
new (&c1.i) int(42); // well-defined
3693+
int j = c1.i; // well-defined
3694+
}
36843695
\end{codeblock}
36853696
\end{example}
36863697
\begin{note}

0 commit comments

Comments
 (0)