public member function
<iterator>

std::istream_iterator::operator++

(1)
istream_iterator& operator++();
(2)
istream_iterator  operator++(int);
Increment iterator position
Advances the istream_iterator by one position.

Internally, the function extracts an element from its associated stream and stores it internally to be returned when dereferenced.

Parameters

none (the second version overloads the post-increment operator).

Return value

The pre-increment version (1) returns *this.
The post-increment version (2) returns the value *this had before the call.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// istream_iterator example
#include <iostream>     // std::cin, std::cout
#include <iterator>     // std::istream_iterator

int main () {
  double value1, value2;
  std::cout << "Please, insert two values: ";

  std::istream_iterator<double> eos;              // end-of-stream iterator
  std::istream_iterator<double> iit (std::cin);   // stdin iterator

  if (iit!=eos) value1=*iit;

  ++iit;
  if (iit!=eos) value2=*iit;

  std::cout << value1 << "*" << value2 << "=" << (value1*value2) << '\n';

  return 0;
}


Data races

Modifies the object.
The iterator returned can be used to access or modify pointed elements.

Exception safety

Basic guarantee: if an exception is thrown, the object is in a valid state.

See also