Problem with tellp()
To verify that a stringstream object is "empty", I use tellp() method in this manner:
if (ss.tellp() == -1)
This code works fine under GCC, but produces an error under MSVC 10.
I think the problem is the comparison with the integer -1.
What is the correct way to use tellp() and what is the correct way to verify that a stringstream object is empty?
Use the str() member of streamstring to return a string calss, and then use string.empty()
That's a novel way to test for empty. This returns 0 with gcc and
std::cout << ss.tellp() << std::endl;
Ok, but I should compare with a 0 integer value the returned value of tellp() and this is the problem...
If it's specifically a stringstream, I'd recomend going with aiby's suggestion above.
Topic archived. No new replies allowed.