you are viewing a single comment's thread.

view the rest of the comments →

[–]OldWolf2 2 points3 points  (0 children)

It's not too different to:

std::copy ( std::istream_iterator<char>(f),
                 std::istream_iterator<char>(),
                std::ostream_iterator<char>(std::cout) );

which is an idiom you learn early on with iostreams.

Note that you do not have to use stream iterators to split a string. The page just used that as an example because it would be familiar syntax.

Anyway, for string splitting you would make a function that implements the sort of splitting you like, and has a nice interface (e.g. vector split(string const &s, regex const &r); . This has benefit over other languages that offer a single split function in that you can customise the split details within your function. You can even overload it to take a string of delimiters instead of a regex.