[libcxx-commits] [PATCH] D157776: [libc++] Eliminate extra allocations from `std::move(oss).str()`

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Aug 12 08:41:57 PDT 2023


philnik requested changes to this revision.
philnik added a comment.
This revision now requires changes to proceed.

Given that there is no requirement in the standard for this, all the tests should be libc++ specific. No implementation is required to have this behaviour.



================
Comment at: libcxx/include/sstream:410
+        }();
         __str_.clear();
         __init_buf_ptrs();
----------------
pfusik wrote:
> I think we don't need this `__str_.clear()` anymore.
We do if the allocator is not equal after copying it. Then the old string isn't cleared.


================
Comment at: libcxx/include/string:973-975
+#if _LIBCPP_STD_VER >= 20
+  // Extension: Support these overloads in C++20 rather than C++23.
+  // Otherwise C++20's `basic_stringbuf::str() &&` is hard to implement.
----------------
Let's not add this as an extension in C++20. It's easy enough to add a private constructor for this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157776/new/

https://reviews.llvm.org/D157776



More information about the libcxx-commits mailing list