gcc/libstdc++-v3/testsuite/24_iterators
Jonathan Wakely 638ad333ec Fix non-standard behaviour of std::istream_iterator
The current implementation of istream_iterator allows the iterator to be
reused after reaching end-of-stream, so that subsequent reads from the
stream can succeed (e.g. if the stream state has been cleared and stream
position changed from EOF). The P0738R2 paper clarified that the
expected behaviour is to set the stream pointer to null after reaching
end-of-stream, preventing further reads.

This implements that requirement, and adds the new default constructor
to std::ostream_iterator.

	* include/bits/stream_iterator.h (istream_iterator::_M_equal()): Make
	private.
	(istream_iterator::_M_read()): Do not check stream state before
	attempting extraction. Set stream pointer to null when extraction
	fails (P0738R2).
	(operator==(const istream_iterator&, const istream_iterator&)): Change
	to be a hidden friend of istream_iterator.
	(operator!=(const istream_iterator&, const istream_iterator&)):
	Likewise.
	(ostream_iterator::ostream_iterator()): Add default constructor.
	(ostream_iterator::ostream_iterator(ostream_type*, const C*)): Use
	addressof.
	* testsuite/24_iterators/istream_iterator/1.cc: New test.
	* testsuite/24_iterators/ostream_iterator/1.cc: New test.
	* testsuite/24_iterators/ostream_iterator/70766.cc: Also check
	constructor taking a string.
	* testsuite/24_iterators/ostream_iterator/requirements/constexpr.cc:
	New test.

From-SVN: r272491
2019-06-19 23:57:10 +01:00
..
back_insert_iterator Update copyright years. 2019-01-01 13:31:55 +01:00
front_insert_iterator Update copyright years. 2019-01-01 13:31:55 +01:00
headers/iterator Update copyright years. 2019-01-01 13:31:55 +01:00
insert_iterator Update copyright years. 2019-01-01 13:31:55 +01:00
istream_iterator Fix non-standard behaviour of std::istream_iterator 2019-06-19 23:57:10 +01:00
istreambuf_iterator Update copyright years. 2019-01-01 13:31:55 +01:00
move_iterator Update copyright years. 2019-01-01 13:31:55 +01:00
normal_iterator Update copyright years. 2019-01-01 13:31:55 +01:00
operations Update copyright years. 2019-01-01 13:31:55 +01:00
ostream_iterator Fix non-standard behaviour of std::istream_iterator 2019-06-19 23:57:10 +01:00
ostreambuf_iterator Update copyright years. 2019-01-01 13:31:55 +01:00
random_access_iterator Update copyright years. 2019-01-01 13:31:55 +01:00
reverse_iterator Update copyright years. 2019-01-01 13:31:55 +01:00
container_access.cc Fix test that gets skipped as unsupported 2019-06-07 20:57:28 +01:00
range_access_cpp14.cc Update copyright years. 2019-01-01 13:31:55 +01:00
range_access_cpp17_neg.cc Update copyright years. 2019-01-01 13:31:55 +01:00
range_access_cpp17.cc Update copyright years. 2019-01-01 13:31:55 +01:00
range_access.cc Update copyright years. 2019-01-01 13:31:55 +01:00