Any way to get an std::string_view from an std::ostringstream without copying?

Viewed 1094
1 Answers

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.

Related