I need write data from some std::ostringstream
to another std::ostringstream
. Of course, I can use str()
function
std::ostringstream in;
std::ostringstream out;
in << "just a test"; // it's just an example. I mean that stream in is filled somewhere
...
out << in.str();
I'd like to know if there is more direct way to do the same.
You can reassign the associated buffers:
That effectively aliases the ostream.
In fact, you can even construct
ostream
directly from a streambuffer pointer IIRCSimilarly, you can append the whole buffer to another stream without reassigning: