
26 Jul
2005
26 Jul
'05
7:16 p.m.
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 );
hm, why thiis works with vc-7_1 then? ;)
for( tokenizer::iterator valueI = values.begin(); valueI != values.end(); ++valueI){ std::cout << "\"" << *valueI << "\"" << std::endl; } }
-- Serge