This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++11 status.
Section: 31.10.4 [ifstream] Status: C++11 Submitter: Niels Dekker Opened: 2008-09-20 Last modified: 2023-02-07
Priority: Not Prioritized
View all issues with C++11 status.
Discussion:
It appears that we have an issue similar to issue 675(i) 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).
[ Batavia (2009-05): ]
Howard agrees with the analysis and the direction proposed.
Move to Open pending specific wording to be supplied by Howard.
[ 2009-07 Frankfurt: ]
Howard is going to write wording.
[ 2009-07-26 Howard provided wording. ]
[ 2009-09-13 Niels adds: ]
Note: The proposed change of 31.10.3.3 [filebuf.assign] p1 depends on the resolution of LWG 1204(i), which allows implementations to assume that
*thisandrhsrefer to different objects.
[ 2009 Santa Cruz: ]
Leave as Open. Too closely related to 911(i) to move on at this time.
[ 2010 Pittsburgh: ]
Moved to Ready for Pittsburgh.
Proposed resolution:
Change 31.8.2.3 [stringbuf.assign]/1:
basic_stringbuf& operator=(basic_stringbuf&& rhs);-1- Effects:
swap(rhs).
Change [istringstream.assign]/1:
basic_istringstream& operator=(basic_istringstream&& rhs);-1- Effects:
swap(rhs).
Change [ostringstream.assign]/1:
basic_ostringstream& operator=(basic_ostringstream&& rhs);-1- Effects:
swap(rhs).
Change [stringstream.assign]/1:
basic_stringstream& operator=(basic_stringstream&& rhs);-1- Effects:
swap(rhs).
Change 31.10.3.3 [filebuf.assign]/1:
basic_filebuf& operator=(basic_filebuf&& rhs);-1- Effects:
swap(rhs).
Change [ifstream.assign]/1:
basic_ifstream& operator=(basic_ifstream&& rhs);-1- Effects:
swap(rhs).
Change [ofstream.assign]/1:
basic_ofstream& operator=(basic_ofstream&& rhs);-1- Effects:
swap(rhs).
Change [fstream.assign]/1:
basic_fstream& operator=(basic_fstream&& rhs);-1- Effects:
swap(rhs).