在像这样的一段代码中
std::string s("random;string;");
std::stringstream s_stream(s);
s_stream会复制s吗?
我的意思是,如果在创建s_stream之后修改了s,会发生什么?
解决方法:
是.从http://en.cppreference.com/w/cpp/io/basic_stringstream/basic_stringstream起
2) Uses a copy of
str
as initial contents of the underlying string device. The underlyingbasic_stringbuf
object is constructed asbasic_stringbuf<Char,Traits,Allocator>(str, mode)
.