[libcxx-commits] [PATCH] D149832: [libc++][ranges] Implement the changes to `basic_string` from P1206 (`ranges::to`):
Konstantin Varlamov via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 16 22:17:08 PDT 2023
var-const added inline comments.
================
Comment at: libcxx/include/string:1326
+ constexpr basic_string& append_range(_Range&& __range) {
+ insert_range(end(), std::forward<_Range>(__range));
+ return *this;
----------------
var-const wrote:
> Original comment by @ldionne
>
> > This one can be more efficient. If we have an input range, then we do need to make a temporary string and append it. But if we have e.g. a `forward_range` or a `sized_range`, we don't need to make a copy of the input range, and I think we should really avoid doing it. I think simply using `insert_range(end(), ...)` here would solve that problem?
Done (here and in `assign_range`).
================
Comment at: libcxx/test/std/strings/basic.string/string.modifiers/string_replace/replace_with_range.pass.cpp:55
+// - cut size: empty / one-element / several elements / until the end;
+// - input range: empty / one-element / middle-sized / longer than SSO / longer than the current string capacity.
+
----------------
var-const wrote:
> Original comment by @ldionne
>
> > `// - input range: empty / one-element / middle-sized / longer than SSO / longer than current string capacity.`
Added a few test cases suffixed with `_LongerThanCapacityRange`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149832/new/
https://reviews.llvm.org/D149832
More information about the libcxx-commits
mailing list