aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2019-06-19 23:57:10 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2019-06-19 23:57:10 +0100
commit638ad333ec544ed7873ed6e13b6f095d6d58fd3b (patch)
treecc296691181aaf4a131f07a799482aba89f10863 /gcc
parent36d0dada6773d7fd7c5ace64c90e723930a3b81e (diff)
downloadgcc-638ad333ec544ed7873ed6e13b6f095d6d58fd3b.zip
gcc-638ad333ec544ed7873ed6e13b6f095d6d58fd3b.tar.gz
gcc-638ad333ec544ed7873ed6e13b6f095d6d58fd3b.tar.bz2
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
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions