In a piece of code like this one
std::string s("random;string;");
std::stringstream s_stream(s);
does s_stream make a copy of s?
I mean, what would happen if, after creating s_stream, I modified s?
Yes. From http://en.cppreference.com/w/cpp/io/basic_stringstream/basic_stringstream
2) Uses a copy of
stras initial contents of the underlying string device. The underlyingbasic_stringbufobject is constructed asbasic_stringbuf<Char,Traits,Allocator>(str, mode).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With