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

I know that you cannot extract std::stringfrom std::ostringstreamwithout copying ( Creating an input stream from read-only memory ).

But is it possible to get std::string_view?

+4
source share
1 answer

String streams are not required to store their data in one continuous array. string_view- this, of course, is an idea of ​​a continuous line.

So no, what you want is impossible. It’s better to wait until C ++ 20 when we get support for moving to / from string streams.

+6
source

Source: https://habr.com/ru/post/1688743/


All Articles