Title
Replacement of class objects containing reference members
Status
cd4
Section
6.7.3 [basic.life]
Submitter
Finland

Created on 2013-09-24.00:00:00 last changed 81 months ago

Messages

Date: 2017-02-15.00:00:00

Notes from the February, 2017 meeting.

The resolution of this issue also resolves issues 636 and 2151.

Date: 2015-10-15.00:00:00

Notes from the October, 2015 meeting:

See also paper P0137 and issue 2182.

Date: 2016-06-15.00:00:00

[Adopted at the June, 2016 meeting as document P0137R1.]

N3690 comment FIĀ 15

The rules given in 6.7.3 [basic.life] paragraph 7 for when an object's lifetime can be ended and a new object created in its storage include the following restriction:

the type of the original object is not const-qualified, and, if a class type, does not contain any non-static data member whose type is const-qualified or a reference type

The intent of this restriction is to permit optimizers to rely upon the original values of const and reference members in their analysis of subsequent code. However, this makes it difficult to implement certain desirable functionality such as optional<T>; see this discussion for more details.

This rule should be reconsidered, at least as far as it applies to unions. If it is decided to keep the rule, acceptable programming techniques for writing safe code when replacing such objects should be outlined in a note.

(See also issue 1404, which will become moot if the restriction is lifted.)

History
Date User Action Args
2018-02-27 00:00:00adminsetmessages: + msg6152
2017-02-06 00:00:00adminsetstatus: drafting -> cd4
2015-11-10 00:00:00adminsetmessages: + msg5639
2014-03-03 00:00:00adminsetstatus: open -> drafting
2013-09-24 00:00:00admincreate