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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.