Meryl Silverburgh wrote:
On 2/20/07, Pavol Droba
wrote: Hi,
There is realy no magic there. You just need to realize, that you are not getting a string, rather a range. Range is a generalization of a pair of iterators.
In case of split_iterator, these iterators point to first and one past the last character of the current token.
Example can be found in /boost/libs/algorithm/string/example/split_example.cpp
Regards, Pavol.
Thanks for your help. I have another question, how can I can i terminate the for loop when loop using string_split?
class integer_compare { public: bool operator() (const string_split::value_type &a, const string_split::value_type &b) { // how can I iterate thru the string? how can i terminate the for loop?
for (const string_split sitr = a; sitr != ???; sitr++) {
// print out each substring (after '/' is stripped out) cout << copy_rangestd::string(*sitr) << endl;
} return true; } };
First of all, I don't understand your example. string_split::value_type is definitely not another split_iterator. it's type is (as I have mentioned in some previous mail) iterator_rangestring::iterator. As for the loop termination, default-initialized split_iterator (i.e. string_split) functions as a terminator. Alternatively you can check the eof() method. Regards, Pavol.