Remember to put parentheses around the first argument. The compiler thinks it's a function declaration otherwise. If you use the vector for just getting iterators for the numbers, you can use the istream iterators directly:

This is a perfect example, imho, of whats wrong with C++. In virtually every other language, this would be a split on ' ', followed by something like .toInt() for each element. Instead, we have an immensely complicated collection of templatized algorithms being applied.
–
dicroceJan 18 '09 at 17:39

3

I hear what you're saying dicroce. OTOH, this more complicated approach is faster, since you avoid creating a temporary array or list of strings, and also more powerful -- much the same code could be used to copy any sort of "range of values" (represented by a pair of iterators) into a vector.
–
j_random_hackerJan 18 '09 at 19:02