|
Boost Users : |
From: Serge Skorokhodov (serge.skorokhodov_at_[hidden])
Date: 2005-07-26 14:16:33
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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net