[libcxx-commits] [libcxx] [lldb] [libcxx] adds a size-based representation for `vector`'s unstable ABI (PR #155330)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jun 18 07:44:48 PDT 2026
================
@@ -196,6 +197,57 @@ public:
swap(__back_cap_, __back_capacity);
}
+ /// Relocates the objects in the range `[__first, __last)` to the front of the buffer, then swaps
+ /// `__first`, `__last`, and `__capacity` with `__begin_`, `__end_`, and `__back_cap_`,
+ /// respectively.
+ ///
+ /// Precondition: `__front_spare() == __last - __first`.
+ /// Exceptions: This function has a strong exception guarantee.
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
+ __relocate(pointer& __first, pointer& __last, pointer& __capacity) {
+ auto __size = __last - __first;
+ auto __new_begin = __begin_ - __size;
+ std::__uninitialized_allocator_relocate(
+ __alloc_, std::__to_address(__first), std::__to_address(__last), std::__to_address(__new_begin));
+ __begin_ = __new_begin;
+ __last = __first;
+
+ __swap_layouts(__first, __last, __capacity);
+ __front_cap_ = __begin_;
+ }
+
+ /// Relocates the objects in the range `[__first, __pivot)` to the front of the buffer, the
+ /// objects in `[__pivot, __last)` into the back of the buffer, then swaps `__first`, `__last`,
+ /// and `__capacity` with `__begin_`, `__end_`, and `__back_cap_`, respectively.
+ ///
+ /// Preconditions:
+ /// * `__front_spare() == __pivot - __first`
+ /// * `__back_spare() == __last - __pivot`
+ /// Exceptions: This function has a strong exception guarantee if `__first == __pivot` or
+ /// `__last - __first == __pivot`.
----------------
ldionne wrote:
What do you mean here? `__last - __first` is a size, but `__pivot` is a pointer, so this doesn't type check. Did you mean `__last == __pivot`?
https://github.com/llvm/llvm-project/pull/155330
More information about the libcxx-commits
mailing list