Hi,
A colleague has recently discovered a problem using tokenizer
with the output from a std::stringstream class in VC8. If we do
the following, we get an "ITERATOR LIST CORRUPTED" exception
thrown:
typedef boost::char_separator<char> Separators;
typedef boost::tokenizer<Separators > Tokens;
std::string str1("ABC");
std::string str2("DEF");
std::stringstream oss;
oss << str1 << "," << str2;
Tokens strList(oss.str(), Separators(",|"));
Tokens::const_iterator strIter = strList.begin(); // exception thrown here
I thought this might be because the string returned from oss.str() is temporary
so I tried the following change and it still failed:
std::string tempStr(oss.str());
Tokens strList(tempStr, Separators(",|"));
Tokens::const_iterator strIter = strList.begin(); // exception thrown here
Finally I tried this and it succeeded.
std::string tempStr;
oss >> tempStr;
Tokens strList(tempStr, Separators(",|"));
Tokens::const_iterator strIter = strList.begin(); // exception thrown here
Can anyone tell me why the first two (in particular the second option) failed?
Regards
Daryl Lilburn
Find out: SEEK Salary Centre Are you paid what you're worth?