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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4