[libcxx-commits] [PATCH] D110598: [libc++] P0980R1 (constexpr std::string)

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 28 01:30:49 PDT 2021


philnik marked 4 inline comments as done.
philnik added inline comments.


================
Comment at: libcxx/include/string:2363-2366
+    if (__libcpp_is_constant_evaluated()) {
+        if (__get_long_pointer() != nullptr)
+            __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());
+    }
----------------
Quuxplusone wrote:
> My understanding of this patch is that you're trying to make it an invariant that "`__libcpp_is_constant_evaluated()` implies `__is_long()`." In that case, you shouldn't need this diff, right?
Yes, this was my plan. But I have to check if it is a nullptr here, because on a moved from object ##__zero()## is called. This way it is not possible using a moved from string in a constexpr context. 


================
Comment at: libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_traits.verify.cpp:25
 template <class charT>
-struct test_traits {
-    typedef charT char_type;
+struct test_traits : std::char_traits<char> {
+  typedef charT char_type;
----------------
Quuxplusone wrote:
> I recommend not inheriting from standard types in general. What causes this change to seem like a good idea? Is `test_traits` missing some members that `std::quoted` needs? Which ones?
 ##basic_string()## needs ##assign## now, because might call ##__init(size_type, value_type)##. Should I just copy/paste it from ##std::char_traits##?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110598



More information about the libcxx-commits mailing list