gcc/libstdc++-v3/include
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
..
backward Remove using-declarations that add std names to __gnu_cxx 2019-05-31 11:35:07 +01:00
bits Fix non-standard behaviour of std::istream_iterator 2019-06-19 23:57:10 +01:00
c
c_compatibility
c_global Avoid undefined behaviour in std::byte operators (LWG 2950) 2019-06-18 12:39:43 +01:00
c_std
debug PR libstdc++/87431 re-adjust never-valueless optimizations 2019-04-05 17:56:09 +01:00
decimal
experimental PR libstdc++/90281 Fix string conversions for filesystem::path 2019-06-17 15:19:04 +01:00
ext Remove using-declarations that add std names to __gnu_cxx 2019-05-31 11:35:07 +01:00
parallel Fix markup for Parallel Mode docs 2019-05-02 16:44:51 +01:00
precompiled Remove array_allocator extension, deprecated since 4.9.0 2019-05-13 11:49:58 +01:00
pstl Synchronize libstdc++ PSTL with upstream LLVM PSTL 2019-06-07 22:01:16 +00:00
std Fix value category bugs in std::reduce 2019-06-19 16:29:49 +01:00
tr1 Improve API docs for mathematical special functions 2019-05-02 16:44:59 +01:00
tr2
Makefile.am Replace std::to_string for integers with optimized version 2019-06-12 15:52:02 +01:00
Makefile.in Replace std::to_string for integers with optimized version 2019-06-12 15:52:02 +01:00