A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.github.io/LWG/issue245 below:

Which operations on istream_iterator trigger input operations?

This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.

245. Which operations on istream_iterator trigger input operations?

Section: 24.6.2 [istream.iterator] Status: NAD Submitter: Andrew Koenig Opened: 2000-05-02 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [istream.iterator].

View all issues with NAD status.

Discussion:

I do not think the standard specifies what operation(s) on istream iterators trigger input operations. So, for example:

        istream_iterator<int> i(cin);

        int n = *i++;

I do not think it is specified how many integers have been read from cin. The number must be at least 1, of course, but can it be 2? More?

Rationale:

The standard is clear as written: the stream is read every time operator++ is called, and it is also read either when the iterator is constructed or when operator* is called for the first time. In the example above, exactly two integers are read from cin.

There may be a problem with the interaction between istream_iterator and some STL algorithms, such as find. There are no guarantees about how many times find may invoke operator++.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4