[英]Any way to get an std::string_view from an std::ostringstream without copying?
I know you can't extract an std::string
from an std::ostringstream
without copying ( Creating an input stream from constant memory ). 我知道你不能在没有复制的情况下从
std::ostringstream
提取std::string
( 从常量内存中创建输入流 )。
But is it possible to get an std::string_view
? 但是有可能得到一个
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. string_view
当然是一个连续字符串的视图。
So no, what you want is not possible. 所以不,你想要的是不可能的。 Best wait till C++20, when we get move support into/outof string-streams.
最好等到C ++ 20,当我们获得进入/退出字符串流的支持时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.