tags:

views:

60

answers:

3

I am sort of confused by this:

 istream_iterator<string> ii(is);
 istream_iterator<string> eos; 
 vector<string> param (ii, eos);
+1  A: 

begin and end iterators. Empty istream_iterator means end of the input.

Mykola Golubyev
A: 

One for start and one for end

RANDOM DATA BEGIN ITERATOR USEFUL DATA END ITERATOR RANDOM DATA

Without "eos", how would the vector know when it has reached the end?

luiscubal
+1  A: 

The constructor for std::vector that takes iterators needs a range, i.e., two iterators that specify where the input range starts and ends (and by end that usually means an iterator one past the end of the range).

Even though you can use input iterators differently, you still need to pass a range to std::vector.

MSN