I know you can't extract an std::string
from an std::ostringstream
without copying (Creating an input stream from constant memory).
But is it possible to get an std::string_view
?
I know you can't extract an std::string
from an std::ostringstream
without copying (Creating an input stream from constant memory).
But is it possible to get an std::string_view
?
String-streams are not required to store their data in a single contiguous array. string_view
is of course a view into a contiguous string.
So no, what you want is not possible. Best wait till C++20, when we get move support into/outof string-streams.