[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:10 PST 2026
================
@@ -1247,17 +1247,18 @@ template <class _Tp, class _Allocator>
template <class... _Args>
_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) {
- pointer __p = this->__begin_ + (__position - begin());
- if (this->__end_ < this->__cap_) {
- if (__p == this->__end_) {
+ pointer __p = this->__begin_ptr() + (__position - begin());
+ if (!__is_full()) {
+ pointer __end = __end_ptr();
+ if (__p == __end) {
__emplace_back_assume_capacity(std::forward<_Args>(__args)...);
} else {
- __temp_value<value_type, _Allocator> __tmp(this->__alloc_, std::forward<_Args>(__args)...);
- __move_range(__p, this->__end_, __p + 1);
+ __temp_value<value_type, _Allocator> __tmp(this->__alloc(), std::forward<_Args>(__args)...);
+ __move_range(__p, __end, __p + 1);
*__p = std::move(__tmp.get());
}
} else {
- __split_buffer<value_type, allocator_type> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);
+ _SplitBuffer __v(__recommend(size() + 1), __p - this->__begin_ptr(), this->__alloc());
----------------
cjdb wrote:
I'm not sure about this one. Your suggestion works well for the current PR and I'd take you up on it if we were sticking with that code model. Changing to composition means that `this->` becomes `__layout_.`, so we're still taking a diff here. Am I missing something? I'll happily make the PR if it reduces the diff.
https://github.com/llvm/llvm-project/pull/155330
More information about the libcxx-commits
mailing list