[libcxx-commits] [libcxx] [libc++] Remove some unnecessary functions from __vector_layout (PR #207152)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 20 07:27:05 PDT 2026


================
@@ -400,7 +400,7 @@ class vector {
     return __layout_.__capacity();
   }
   [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {
-    return __layout_.__empty();
+    return size() == 0;
----------------
ldionne wrote:

I wasn't aware of (and didn't expect) this breakage before I read this. It seems like the original `_LIBCPP_ABI_VECTOR_LAYOUT_SIZE_BASED` patch indeed changed whether `vector` requires complete types to compute `empty()`. I can confirm that here: https://godbolt.org/z/EMff4KPjP. This was unintended, and we should fix that at least until we decide we want to change that guarantee. I filed https://github.com/llvm/llvm-project/issues/210732 for that.

I think this should also resolve your concern about different requirements depending on the ABI macro.

https://github.com/llvm/llvm-project/pull/207152


More information about the libcxx-commits mailing list