I want to overwrite the string in an std::ostringstream
but std::ends
isn't working. Is this a problem with VS2012, or am I doing something wrong? Here is example code:
std::ostringstream foo;
foo << "1,2,3,4,5,6";
std::cout << foo.str(); // prints: 1,2,3,4,5,6
foo.clear();
foo.seekp( std::ios_base::beg );
foo << "A,B,C" << std::ends;
std::cout << foo.str(); // prints: A,B,C,4,5,6 NOT just: A,B,C
EDIT:
I'm getting a lot of answers that I can use foo.str( std::string() )
to clear the string... I know that. This question is a spin off from here: How to reuse an ostringstream?
I'm trying not to reallocate the buffer.