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

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 7 08:39:48 PDT 2022


ldionne accepted this revision.
ldionne added inline comments.
This revision is now accepted and ready to land.


================
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;
----------------
ldionne wrote:
> 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.
Marked as done, but not done?


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

```
// We can't compare unrelated pointers inside constant expressions
```

in both places?


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