[libcxx-commits] [libcxx] [libcxx] adds a size-based representation for `vector`'s unstable ABI (PR #155330)
Christopher Di Bella via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 11 00:36:16 PST 2026
================
@@ -1267,25 +1268,26 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) {
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) {
- pointer __p = this->__begin_ + (__position - begin());
+ pointer __p = this->__begin_ptr() + (__position - begin());
if (__n > 0) {
- if (__n <= static_cast<size_type>(this->__cap_ - this->__end_)) {
+ if (__n <= __remaining_capacity()) {
size_type __old_n = __n;
- pointer __old_last = this->__end_;
- if (__n > static_cast<size_type>(this->__end_ - __p)) {
- size_type __cx = __n - (this->__end_ - __p);
+ pointer __end = __end_ptr();
+ pointer __old_last = __end;
+ if (__n > static_cast<size_type>(__end - __p)) {
+ size_type __cx = __n - (__end - __p);
__construct_at_end(__cx, __x);
__n -= __cx;
}
if (__n > 0) {
__move_range(__p, __old_last, __p + __old_n);
const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
- if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end_), std::addressof(__x)))
+ if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end), std::addressof(__x)))
__xr += __old_n;
std::fill_n(__p, __n, *__xr);
}
} else {
- __split_buffer<value_type, allocator_type> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_);
+ _SplitBuffer __v(__recommend(size() + __n), __p - this->__begin_ptr(), this->__alloc());
----------------
cjdb wrote:
Done in #180284.
https://github.com/llvm/llvm-project/pull/155330
More information about the libcxx-commits
mailing list