A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/llvm/llvm-project/issues/64644 below:

C++20 std::move(ss).str() first copies and then delete the original string instead of moving it · Issue #64644 · llvm/llvm-project · GitHub

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