[libcxx-commits] [PATCH] D68840: [libc++][P0980] Marked member functions move/copy/assign of char_traits constexpr.

Michael Park via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 16 15:17:27 PDT 2019


mpark added inline comments.


================
Comment at: libcxx/include/__string:203
+static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
+_CharT* __move_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT
+{
----------------
ldionne wrote:
> `__memmove_constexpr`?
I decided against this name here because this is more refactoring of the `move` algorithm for `constexpr`.
Specifically, we use this as the `constexpr` version of `wmemmove` as well as `memmmove`.

Same line of reasoning for the below requests.


================
Comment at: libcxx/include/__string:656
 {
+    if (__n == 0) return __s1;
     char_type* __r = __s1;
----------------
ldionne wrote:
> Is that necessary?
Yes, this is necessary due to this test:
```
assert(std::char_traits<char16_t>::move(NULL, s1, 0) == NULL);
```
where, if `n == 0`, we should not perform the `__s1 < __s2` check since that is UB.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68840





More information about the libcxx-commits mailing list