The extra trailing increment on ranges::copy_n causes trouble when you use it with an istream_iterator source, as istream_iterator performs an irreversible action on increment.
Essentially, this will consume 6 ints from the source stream, instead of 5:
See also: https://cplusplus.github.io/LWG/issue2471
The extra trailing increment on ranges::copy_n causes trouble when you use it with an istream_iterator source, as istream_iterator performs an irreversible action on increment.
Essentially, this will consume 6 ints from the source stream, instead of 5:
A similar issue exists with copy, take, and istream_view - the following will consume 6 ints from the source stream also: