istream_iteratorallows you to iteratively retrieve elements from istreamthat you pass to the constructor. The object eofis explained as follows:
: end-the-stream; , ( void *, , false) ( basic_istream).
for_each - , # 1 , # 2. , cin ( ) , - - input eof, .
[&] (int x) { frequency[x]++; } ; inline.
unordered_map<int,int> frequency;
istream_iterator<int> input(cin);
istream_iterator<int> eof;
void consume(int x) {
frequency[x]++;
}
for_each(input, eof, consume);
, : , , .