D
Dilip
Hi
I have a pretty simply task of splitting a std::string that has a comma
separated list of names. I know the usual brute force method to do
this (with basic_string::find_first_of and friends). However I am sure
there is a way to do use std::copy along with ostream_iterator or
istream_iterator. I tried various different combianations but I cannot
quite figure out how to do it. Is there a way?
I do know that...
std::string str("name1,name2");
vector<string> splitstrings;
std::copy(<something goes here>, <anotehr iterator goes here>,
splitstrings.begin());
I tried a lot of embarassing things for the 1st 2 arguments of
std::copy but couldnt quite get it to work the way I want it.
I want to learn as much as possible about STL algorithms and am trying
to restrict myself to them wherever possible instead of quickly
reaching for the easiest method to do it.
I have a pretty simply task of splitting a std::string that has a comma
separated list of names. I know the usual brute force method to do
this (with basic_string::find_first_of and friends). However I am sure
there is a way to do use std::copy along with ostream_iterator or
istream_iterator. I tried various different combianations but I cannot
quite figure out how to do it. Is there a way?
I do know that...
std::string str("name1,name2");
vector<string> splitstrings;
std::copy(<something goes here>, <anotehr iterator goes here>,
splitstrings.begin());
I tried a lot of embarassing things for the 1st 2 arguments of
std::copy but couldnt quite get it to work the way I want it.
I want to learn as much as possible about STL algorithms and am trying
to restrict myself to them wherever possible instead of quickly
reaching for the easiest method to do it.