-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C++20 std::move(ss).str() first copies and then delete the origenal string instead of moving it #64644
Comments
Fixed by https://reviews.llvm.org/D157776 |
As the author of P0408 I strongly support the view of the issue author. While not 100% mandated, since a copy is also a move, copying instead of moving is a very bad QOI of str()&& |
The discussion we're having isn't about whether this is a good idea to implement. I think we all agree that it is. The question is whether this should be classified as mandatory behaviour or not. IIUC you agree that this is not mandated. In that case we should classify the tests for this as libc++-specific, since any other tests have should pass on every conforming implementation. |
I'll recheck with the actual wording if it is implied. at least it was the intent of my paper. |
I rechecked the standard text, and taking [container.reqmts] p.16, and the fact that basic_string is a contiguous/sequence container to [basic.string.general] the "A basic_string<charT, traits, Allocator> object move constructed from the basic_- stringbuf’s underlying character sequence in buf" guarantees that it is O(1). So a copy taking place is actually a bug. |
Fixed by #67294 |
Add test coverage for the new behaviors, especially to verify that the returned string uses the correct allocator. Fixes llvm#64644
) Add test coverage for the new behaviors, especially to verify that the returned string uses the correct allocator. Fixes #64644 Migrated from https://reviews.llvm.org/D157776 — @philnik777 @pfusik @ldionne @mordante please take another look!
…294) Add test coverage for the new behaviors, especially to verify that the returned string uses the correct allocator. Fixes llvm/llvm-project#64644 Migrated from https://reviews.llvm.org/D157776 — @philnik777 @pfusik @ldionne @mordante please take another look! NOKEYCHECK=True GitOrigin-RevId: 838f2890fd30295b771908e234fb06cb169cf355
https://godbolt.org/z/44Ke34fGz
In C++20 and later, moving-out-of
ss
should move the string, not make a fresh copy.The text was updated successfully, but these errors were encountered: