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

Nico Weber via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 16 08:42:06 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;
----------------
nico wrote:

`size()` has to do arithmetic on the pointers, which requires complete types. The LHS, and vector before _LIBCPP_ABI_VECTOR_LAYOUT_SIZE_BASED, didn't require complete types to call `empty()`.

Compete types are only needed if `_LIBCPP_ABI_VECTOR_LAYOUT_SIZE_BASED` is not defined, which means it is now ABI-dependent if a type has to be complete.

This also means *not* enabling `_LIBCPP_ABI_VECTOR_LAYOUT_SIZE_BASED` stops building for us for that reason. (And building with it causes a big size regression that we're currently investigating.)

As @ldionne says in https://github.com/llvm/llvm-project/pull/155330#pullrequestreview-4612029839, `_LIBCPP_ABI_VECTOR_LAYOUT_SIZE_BASED` seems like a risky change. Maybe we shouldn't make it harder to turn it off.

Could we maybe undo this change here to make it easier to compare behavior with the new layout on and off?

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


More information about the libcxx-commits mailing list