[libcxx-commits] [libcxx] [libcxx] adds a size-based representation for `vector`'s unstable ABI (PR #155330)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Feb 6 07:08:13 PST 2026


================
@@ -862,47 +857,52 @@ template <ranges::input_range _Range,
 vector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_t<_Range>, _Alloc>;
 #endif
 
-// __swap_out_circular_buffer relocates the objects in [__begin_, __end_) into the front of __v and swaps the buffers of
-// *this and __v. It is assumed that __v provides space for exactly (__end_ - __begin_) objects in the front. This
+// __swap_out_circular_buffer relocates the objects in [__begin_ptr(), size()) into the front of __v and swaps the
+// buffers of *this and __v. It is assumed that __v provides space for exactly size() objects in the front. This
 // function has a strong exception guarantee.
 template <class _Tp, class _Allocator>
-_LIBCPP_CONSTEXPR_SINCE_CXX20 void
-vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type>& __v) {
+_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__swap_out_circular_buffer(_SplitBuffer& __v) {
   __annotate_delete();
   auto __new_begin = __v.begin() - size();
   std::__uninitialized_allocator_relocate(
-      this->__alloc_, std::__to_address(__begin_), std::__to_address(__end_), std::__to_address(__new_begin));
+      this->__alloc(),
+      std::__to_address(__begin_ptr()),
+      std::__to_address(__end_ptr()),
+      std::__to_address(__new_begin));
   __v.__set_valid_range(__new_begin, __v.end());
-  __end_ = __begin_; // All the objects have been destroyed by relocating them.
+  __set_boundary(static_cast<size_type>(0)); // All the objects have been destroyed by relocating them.
----------------
ldionne wrote:

I just realized that something quite subtle is happening here. I presume this would be an ambiguous call if you dropped `static_cast<size_type>` since it could either be trying to call `__set_boundary(pointer)` or `__set_boundary(size_type)`, is that right?

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


More information about the libcxx-commits mailing list