Jonathan Mcdougall wrote:
Dilip wrote:
red floyd wrote:
Thanks! I knew this method. Academically I would still love to know
if its possible to use std::copy to do what I want.
I cannot use Boost due to company policy issues.
Well using std::string's iterator, it's impossible. On top of my head,
you could wrap up the iterator into a class of your own that implements
operator++ (advances past the next separator) and operator* (returns a
string from the current position to the next separator/end) and then
std::copy(my_iter(s.begin()), my_iter(s.end()), std::back_insert(v));
Jonathan
Thanks for the explanation. Its becomign clearer what is and what is
not possible. I have a quick followup question. I gathered that I can
do something like this using std::copy - that is, read a stream of
input from cin (terminated by \n) and dump them into a vector like so:
istream_iterator<int> readInput(cin);
std::copy(readInput, istream_iterator<int>(), myvector.begin());
cannot we use a similar analogy? an input string stream should be
conceptually identical to a standard input stream, right? i did notice
istream_iterator doesn't offer a way to specify a delimiter.
Actually, it does, though it is quite complicated. Have a look at this:
http://groups.google.co.uk/group/microsoft.public.vc.stl/browse_frm/thread/711ee3e4cabab899/7b3c68d5bef58d39