*itr
will actually return basic_string
instead of string
, so you need to convert one to another:
using namespace std; using namespace boost; void fn_that_receives_pointer_to_std_string(string* str) { cout << "str: " << *str << endl; } int main() { string s = "Field 1,\"putting quotes around fields, allows commas\",Field 3"; tokenizer<escaped_list_separator<char> > tok(s); for(tokenizer<escaped_list_separator<char> >::iterator beg=tok.begin(); beg!=tok.end();++beg) { string tmp(*beg); fn_that_receives_pointer_to_std_string(&tmp); } }
I don't like the idea of ββpassing the memory address of string
another function. Consider transferring it with a copy or link.
source share