[libcxx-commits] [PATCH] D68365: [libc++] Implement P1004R2 (constexpr std::vector)

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 6 14:52:36 PDT 2022


ldionne requested changes to this revision.
ldionne added inline comments.
This revision now requires changes to proceed.


================
Comment at: libcxx/include/__bit_reference:388
     __storage_type __nw = __n / __bits_per_word;
-    _VSTD::memset(_VSTD::__to_address(__first.__seg_), -1, __nw * sizeof(__storage_type));
+    std::fill_n(std::__to_address(__first.__seg_), __nw, -1);
     __n -= __nw * __bits_per_word;
----------------
I think it would be more obvious if we at least used `static_cast<__storage_type>(-1)`.

Either way we should probably add a comment.


================
Comment at: libcxx/include/vector:1700
     pointer __p = this->__begin_ + (__position - begin());
-    if (this->__end_ < this->__end_cap())
+    if (!__libcpp_is_constant_evaluated() && this->__end_ < this->__end_cap())
     {
----------------
What happens if we remove this condition? If the issue is with comparing pointers to unrelated areas of memory, what happens when you use `std::less` to perform the comparison instead? `std::less` has a special blessing when it comes to comparing unrelated pointers (yes, it's crazy).


================
Comment at: libcxx/include/vector:1797
     {
-        if (__n <= static_cast<size_type>(this->__end_cap() - this->__end_))
+        if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__end_cap() - this->__end_))
         {
----------------
What happens if we remove this condition?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68365



More information about the libcxx-commits mailing list