[basic.life] Reference [intro.object] in transparent replacement note and improve example #7331
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Recently, it was really difficult for me to find out what happens when you transparently replace a subobject. [basic.life] p9 does not elaborate on this; the relevant parts are in [intro.object] p2.
Namely, the containing object is kept alive if the conditions are met and can be used to access the new subobject. A new note highlights this behavior and links back to [intro.object].
Furthermore, [basic.life] Example 3 is currently ill-formed (fixed by this PR) because it contains
c1 = c2;
at a top level, which should be taking place in a function body. The example is further expanded by two lines that demonstrate how a containing object survives when transparent replacement of one of its subobjects takes place.