boost.tokenizer (escaped_list_separator) problem

Hello Why will the following code make my application crash: int main(){ std::string s = "Field 1 \"putting quotes around fields, allows commas\",Field 3"; boost::escaped_list_separator<char> sep("\"\'", " ,;", "\"\'"); boost::tokenizer<boost::escaped_list_separator<char> > tok(s, sep); for(boost::tokenizer<boost::escaped_list_separator<char> >::iterator beg=tok.begin(); beg!=tok.end();++beg){ std::cout << *beg << "\n"; } } What am I doing wrong? Many thanks in advance! Aljaz

Aljaz schrieb:
Hello
Why will the following code make my application crash:
int main(){ std::string s = "Field 1 \"putting quotes around fields, allows commas\",Field 3";
boost::escaped_list_separator<char> sep("\"\'", " ,;", "\"\'"); boost::tokenizer<boost::escaped_list_separator<char> > tok(s, sep);
for(boost::tokenizer<boost::escaped_list_separator<char> >::iterator beg=tok.begin(); beg!=tok.end();++beg){ std::cout << *beg << "\n"; } }
What am I doing wrong? Many thanks in advance!
Aljaz
Maybe you try to surround the code in main with try { ... } catch(std::exception& e){ std::cout << e.what() << std::endl } Possibly the tokenizer throws an exception that shows the reason.

AMDG Maximilian Matthe wrote:
Aljaz schrieb:
std::string s = "Field 1 \"putting quotes around fields, allows commas\",Field 3";
boost::escaped_list_separator<char> sep("\"\'", " ,;", "\"\'");
<snip>
I think what you want is: boost::escaped_list_separator<char> sep("\\", " ,;", "\"\'"); In Christ, Steven Watanabe

Many thanks for help! Thats what I've been looking for! "Steven Watanabe" <watanabesj@gmail.com> wrote in message news:487CEBF7.3030108@providere-consulting.com...
AMDG
Maximilian Matthe wrote:
Aljaz schrieb:
std::string s = "Field 1 \"putting quotes around fields, allows commas\",Field 3";
boost::escaped_list_separator<char> sep("\"\'", " ,;", "\"\'");
<snip>
I think what you want is:
boost::escaped_list_separator<char> sep("\\", " ,;", "\"\'");
In Christ, Steven Watanabe
participants (3)
-
Aljaz
-
Maximilian Matthe
-
Steven Watanabe