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

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 7 08:18:14 PDT 2022


philnik added inline comments.


================
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())
     {
----------------
ldionne wrote:
> 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).
It still complains that the pointers are unrelated.


================
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_))
         {
----------------
ldionne wrote:
> What happens if we remove this condition?
Here it also complains about comparing unrelated pointers.


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