Read a line of values
This sample is licensed under the CC0 Public Domain Dedication.
Read a sequence of delimited values from a single line of an input stream into a standard container.
On line 7, we declare a
as the input stream, although any other input stream could be used.
For user input, you can simply replace
std::cin. We have similarly used
std::vector as an example container
To iterate over the stream, we use the
on line 10, which internally uses
operator>> to extract
std::istream_iterator<int> on line 11 denotes
the end of the stream.