https://godbolt.org/z/44Ke34fGz
std::stringstream ss("a very long string that exceeds the small string optimization buffer length");
const char *p = ss.view().data();
std::string s = std::move(ss).str();
assert(s.data() == p); // shouldn't be a second allocation
In C++20 and later, moving-out-of ss should move the string, not make a fresh copy.
https://godbolt.org/z/44Ke34fGz
In C++20 and later, moving-out-of
ssshould move the string, not make a fresh copy.