
27 Jul
2005
27 Jul
'05
9:13 a.m.
Serge Skorokhodov <serge.skorokhodov@tochka.ru> writes:
Jeff Flinn wrote:
Jarl Friis wrote:
Hi.
I discovered the following problem using boost::tokenizer. The following program should print "hello", but it prints "hell":
#include <iostream> #include <boost/tokenizer.hpp>
int main(){ typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep(",", ""); tokenizer values(std::string(",hello,"), sep);
Your string is a temporary and goes out of scope. Try:
std::string test(",hello,");
tokenizer values( test, sep );
Thanks, that helped.
hm, why thiis works with vc-7_1 then? ;)
I gues accoriding to the standard, it is undefined behaviour, so it might work, you just can't rely on it. Jarl