This is basically what I want to do.
int main(int argc, char* argv[])
{
std::stringstream ss;
ss << "12345";
ss.seekp(-1, std::ios::end);
ss << '\0';
assert(ss.str() == "1234"); // nope!
return 0;
}
This question seems like a duplicate, but the answer is about writing a sequence of tokens and not actually addresses the original question.