Title
Stream move-assignment
Status
c++11
Section
[ifstream]
Submitter
Niels Dekker

Created on 2008-09-20.00:00:00 last changed 162 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Change [stringbuf.assign]/1:

basic_stringbuf& operator=(basic_stringbuf&& rhs);

-1- Effects: swap(rhs). After the move assignment *this reflects the same observable state it would have if it had been move constructed from rhs ([stringbuf.cons]).

Change [istringstream.assign]/1:

basic_istringstream& operator=(basic_istringstream&& rhs);

-1- Effects: swap(rhs). Move assigns the base and members of *this with the respective base and members of rhs.

Change [ostringstream.assign]/1:

basic_ostringstream& operator=(basic_ostringstream&& rhs);

-1- Effects: swap(rhs). Move assigns the base and members of *this with the respective base and members of rhs.

Change [stringstream.assign]/1:

basic_stringstream& operator=(basic_stringstream&& rhs);

-1- Effects: swap(rhs). Move assigns the base and members of *this with the respective base and members of rhs.

Change [filebuf.assign]/1:

basic_filebuf& operator=(basic_filebuf&& rhs);

-1- Effects: swap(rhs). Begins by calling this->close(). After the move assignment *this reflects the same observable state it would have if it had been move constructed from rhs ([filebuf.cons]).

Change [ifstream.assign]/1:

basic_ifstream& operator=(basic_ifstream&& rhs);

-1- Effects: swap(rhs). Move assigns the base and members of *this with the respective base and members of rhs.

Change [ofstream.assign]/1:

basic_ofstream& operator=(basic_ofstream&& rhs);

-1- Effects: swap(rhs). Move assigns the base and members of *this with the respective base and members of rhs.

Change [fstream.assign]/1:

basic_fstream& operator=(basic_fstream&& rhs);

-1- Effects: swap(rhs). Move assigns the base and members of *this with the respective base and members of rhs.

Date: 2010-10-21.18:28:33

[ 2010 Pittsburgh: ]

Moved to Ready for Pittsburgh.

Date: 2010-10-21.18:28:33

[ 2009 Santa Cruz: ]

Leave as Open. Too closely related to 911 to move on at this time.

Date: 2009-09-13.00:00:00

[ 2009-09-13 Niels adds: ]

Note: The proposed change of [filebuf.assign] p1 depends on the resolution of LWG 1204, which allows implementations to assume that *this and rhs refer to different objects.

Date: 2009-07-26.00:00:00

[ 2009-07-26 Howard provided wording. ]

Date: 2010-10-21.18:28:33

[ 2009-07 Frankfurt: ]

Howard is going to write wording.

Date: 2010-10-21.18:28:33

[ Batavia (2009-05): ]

Howard agrees with the analysis and the direction proposed.

Move to Open pending specific wording to be supplied by Howard.

Date: 2008-09-20.00:00:00

It appears that we have an issue similar to issue 675 regarding the move-assignment of stream types. For example, when assigning to an std::ifstream, ifstream1, it seems preferable to close the file originally held by ifstream1:

ifstream1 = std::move(ifstream2); 

The current Draft (N2723) specifies that the move-assignment of stream types like ifstream has the same effect as a swap:

Assign and swap [ifstream.assign]

basic_ifstream& operator=(basic_ifstream&& rhs); 

Effects: swap(rhs).

History
Date User Action Args
2011-08-23 20:07:26adminsetstatus: wp -> c++11
2010-10-21 18:28:33adminsetmessages: + msg4287
2010-10-21 18:28:33adminsetmessages: + msg4286
2010-10-21 18:28:33adminsetmessages: + msg4285
2010-10-21 18:28:33adminsetmessages: + msg4284
2010-10-21 18:28:33adminsetmessages: + msg4283
2010-10-21 18:28:33adminsetmessages: + msg4282
2010-10-21 18:28:33adminsetmessages: + msg4281
2008-09-20 00:00:00admincreate