[libcxx-commits] [PATCH] D123058: [libc++] Remove the usage of __init in operator+
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Apr 8 13:27:49 PDT 2022
ldionne requested changes to this revision.
ldionne added inline comments.
This revision now requires changes to proceed.
================
Comment at: libcxx/include/string:767
+ _LIBCPP_HIDE_FROM_ABI basic_string(__uninitialized_size_tag, size_type __size, const allocator_type& __a)
+ : __r_(__default_init_tag(), __a) {
----------------
Let's make it `explicit`.
Can you also add a comment documenting what this constructor does? Something like:
```
// Construct a string with the given allocator and enough storage to hold `__size` characters, but
// don't initialize the characters. The contents of the string, including the null terminator, must be
// initialized separately.
```
================
Comment at: libcxx/include/string:769
+ : __r_(__default_init_tag(), __a) {
+ if (__fits_in_sso(__size)) {
+ __zero();
----------------
We need to handle the case where `__size > max_size()` like we used to in `__init`.
================
Comment at: libcxx/include/string:4207
+ _Traits::copy(__r.data() + __lhs_sz, __rhs.data(), __rhs_sz);
+ _Traits::assign(__r.data() + __lhs_sz + __rhs_sz, 1, '\0');
return __r;
----------------
This would need to be `value_type()` instead of `'\0'`. We support non-`char` character types as well.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123058/new/
https://reviews.llvm.org/D123058
More information about the libcxx-commits
mailing list