2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___SPLIT_BUFFER
11 #define _LIBCPP___SPLIT_BUFFER
13 #include <__algorithm/max.h>
14 #include <__algorithm/move.h>
15 #include <__algorithm/move_backward.h>
17 #include <__cstddef/size_t.h>
18 #include <__iterator/distance.h>
19 #include <__iterator/iterator_traits.h>
20 #include <__iterator/move_iterator.h>
21 #include <__memory/allocate_at_least.h>
22 #include <__memory/allocator.h>
23 #include <__memory/allocator_traits.h>
24 #include <__memory/compressed_pair.h>
25 #include <__memory/pointer_traits.h>
26 #include <__memory/swap_allocator.h>
27 #include <__type_traits/add_lvalue_reference.h>
28 #include <__type_traits/conditional.h>
29 #include <__type_traits/enable_if.h>
30 #include <__type_traits/integral_constant.h>
31 #include <__type_traits/is_nothrow_assignable.h>
32 #include <__type_traits/is_nothrow_constructible.h>
33 #include <__type_traits/is_swappable.h>
34 #include <__type_traits/is_trivially_destructible.h>
35 #include <__type_traits/is_trivially_relocatable.h>
36 #include <__type_traits/remove_reference.h>
37 #include <__utility/forward.h>
38 #include <__utility/move.h>
40 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
41 # pragma GCC system_header
45 #include <__undef_macros>
47 _LIBCPP_BEGIN_NAMESPACE_STD
49 // __split_buffer allocates a contiguous chunk of memory and stores objects in the range [__begin_, __end_).
50 // It has uninitialized memory in the ranges [__first_, __begin_) and [__end_, __cap_). That allows
51 // it to grow both in the front and back without having to move the data.
53 template <class _Tp, class _Allocator = allocator<_Tp> >
54 struct __split_buffer {
56 using value_type = _Tp;
57 using allocator_type = _Allocator;
58 using __alloc_rr = __libcpp_remove_reference_t<allocator_type>;
59 using __alloc_traits = allocator_traits<__alloc_rr>;
60 using reference = value_type&;
61 using const_reference = const value_type&;
62 using size_type = typename __alloc_traits::size_type;
63 using difference_type = typename __alloc_traits::difference_type;
64 using pointer = typename __alloc_traits::pointer;
65 using const_pointer = typename __alloc_traits::const_pointer;
66 using iterator = pointer;
67 using const_iterator = const_pointer;
69 // A __split_buffer contains the following members which may be trivially relocatable:
70 // - pointer: may be trivially relocatable, so it's checked
71 // - allocator_type: may be trivially relocatable, so it's checked
72 // __split_buffer doesn't have any self-references, so it's trivially relocatable if its members are.
73 using __trivially_relocatable = __conditional_t<
74 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,
81 _LIBCPP_COMPRESSED_PAIR(pointer, __cap_, allocator_type, __alloc_);
83 __split_buffer(const __split_buffer&) = delete;
84 __split_buffer& operator=(const __split_buffer&) = delete;
86 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer()
87 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
88 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr) {}
90 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(__alloc_rr& __a)
91 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr), __alloc_(__a) {}
93 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(const __alloc_rr& __a)
94 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr), __alloc_(__a) {}
96 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
97 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
99 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c)
100 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
102 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
104 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer& operator=(__split_buffer&& __c)
105 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
106 is_nothrow_move_assignable<allocator_type>::value) ||
107 !__alloc_traits::propagate_on_container_move_assignment::value);
109 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~__split_buffer();
111 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __begin_; }
112 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __begin_; }
114 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __end_; }
115 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __end_; }
117 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __destruct_at_end(__begin_); }
119 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const {
120 return static_cast<size_type>(__end_ - __begin_);
123 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const { return __end_ == __begin_; }
125 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const {
126 return static_cast<size_type>(__cap_ - __first_);
129 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __front_spare() const {
130 return static_cast<size_type>(__begin_ - __first_);
133 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() const {
134 return static_cast<size_type>(__cap_ - __end_);
137 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() { return *__begin_; }
138 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const { return *__begin_; }
139 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() { return *(__end_ - 1); }
140 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const { return *(__end_ - 1); }
142 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
144 template <class... _Args>
145 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);
146 template <class... _Args>
147 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args);
149 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_front() { __destruct_at_begin(__begin_ + 1); }
150 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back() { __destruct_at_end(__end_ - 1); }
152 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);
153 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x);
155 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
156 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
157 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
159 template <class _Iterator, class _Sentinel>
160 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
161 __construct_at_end_with_sentinel(_Iterator __first, _Sentinel __last);
163 template <class _Iterator>
164 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
165 __construct_at_end_with_size(_Iterator __first, size_type __n);
167 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_begin(pointer __new_begin) {
168 __destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());
171 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_begin(pointer __new_begin, false_type);
172 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_begin(pointer __new_begin, true_type);
174 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last) _NOEXCEPT {
175 __destruct_at_end(__new_last, false_type());
178 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;
179 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;
181 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer& __x)
182 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__alloc_rr>);
184 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
187 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer& __c, true_type)
188 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
189 __alloc_ = std::move(__c.__alloc_);
192 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT {}
194 struct _ConstructTransaction {
195 _LIBCPP_CONSTEXPR_SINCE_CXX20
196 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
201 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() { *__dest_ = __pos_; }
204 const pointer __end_;
211 template <class _Tp, class _Allocator>
212 _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, _Allocator>::__invariants() const {
213 if (__first_ == nullptr) {
214 if (__begin_ != nullptr)
216 if (__end_ != nullptr)
218 if (__cap_ != nullptr)
221 if (__begin_ < __first_)
223 if (__end_ < __begin_)
231 // Default constructs __n objects starting at __end_
232 // throws if construction throws
233 // Precondition: __n > 0
234 // Precondition: size() + __n <= capacity()
235 // Postcondition: size() == size() + __n
236 template <class _Tp, class _Allocator>
237 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) {
238 _ConstructTransaction __tx(&this->__end_, __n);
239 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
240 __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_));
244 // Copy constructs __n objects starting at __end_ from __x
245 // throws if construction throws
246 // Precondition: __n > 0
247 // Precondition: size() + __n <= capacity()
248 // Postcondition: size() == old size() + __n
249 // Postcondition: [i] == __x for all i in [size() - __n, __n)
250 template <class _Tp, class _Allocator>
251 _LIBCPP_CONSTEXPR_SINCE_CXX20 void
252 __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) {
253 _ConstructTransaction __tx(&this->__end_, __n);
254 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
255 __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), __x);
259 template <class _Tp, class _Allocator>
260 template <class _Iterator, class _Sentinel>
261 _LIBCPP_CONSTEXPR_SINCE_CXX20 void
262 __split_buffer<_Tp, _Allocator>::__construct_at_end_with_sentinel(_Iterator __first, _Sentinel __last) {
263 __alloc_rr& __a = __alloc_;
264 for (; __first != __last; ++__first) {
265 if (__end_ == __cap_) {
266 size_type __old_cap = __cap_ - __first_;
267 size_type __new_cap = std::max<size_type>(2 * __old_cap, 8);
268 __split_buffer __buf(__new_cap, 0, __a);
269 for (pointer __p = __begin_; __p != __end_; ++__p, (void)++__buf.__end_)
270 __alloc_traits::construct(__buf.__alloc_, std::__to_address(__buf.__end_), std::move(*__p));
273 __alloc_traits::construct(__a, std::__to_address(this->__end_), *__first);
277 template <class _Tp, class _Allocator>
278 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >
279 _LIBCPP_CONSTEXPR_SINCE_CXX20 void
280 __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) {
281 __construct_at_end_with_size(__first, std::distance(__first, __last));
284 template <class _Tp, class _Allocator>
285 template <class _ForwardIterator>
286 _LIBCPP_CONSTEXPR_SINCE_CXX20 void
287 __split_buffer<_Tp, _Allocator>::__construct_at_end_with_size(_ForwardIterator __first, size_type __n) {
288 _ConstructTransaction __tx(&this->__end_, __n);
289 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__first) {
290 __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), *__first);
294 template <class _Tp, class _Allocator>
295 _LIBCPP_CONSTEXPR_SINCE_CXX20 inline void
296 __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) {
297 while (__begin_ != __new_begin)
298 __alloc_traits::destroy(__alloc_, std::__to_address(__begin_++));
301 template <class _Tp, class _Allocator>
302 _LIBCPP_CONSTEXPR_SINCE_CXX20 inline void
303 __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type) {
304 __begin_ = __new_begin;
307 template <class _Tp, class _Allocator>
308 _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void
309 __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT {
310 while (__new_last != __end_)
311 __alloc_traits::destroy(__alloc_, std::__to_address(--__end_));
314 template <class _Tp, class _Allocator>
315 _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void
316 __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT {
320 template <class _Tp, class _Allocator>
321 _LIBCPP_CONSTEXPR_SINCE_CXX20
322 __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
323 : __cap_(nullptr), __alloc_(__a) {
327 auto __allocation = std::__allocate_at_least(__alloc_, __cap);
328 __first_ = __allocation.ptr;
329 __cap = __allocation.count;
331 __begin_ = __end_ = __first_ + __start;
332 __cap_ = __first_ + __cap;
335 template <class _Tp, class _Allocator>
336 _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::~__split_buffer() {
339 __alloc_traits::deallocate(__alloc_, __first_, capacity());
342 template <class _Tp, class _Allocator>
343 _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
344 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
345 : __first_(std::move(__c.__first_)),
346 __begin_(std::move(__c.__begin_)),
347 __end_(std::move(__c.__end_)),
348 __cap_(std::move(__c.__cap_)),
349 __alloc_(std::move(__c.__alloc_)) {
350 __c.__first_ = nullptr;
351 __c.__begin_ = nullptr;
352 __c.__end_ = nullptr;
353 __c.__cap_ = nullptr;
356 template <class _Tp, class _Allocator>
357 _LIBCPP_CONSTEXPR_SINCE_CXX20
358 __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
359 : __cap_(nullptr), __alloc_(__a) {
360 if (__a == __c.__alloc_) {
361 __first_ = __c.__first_;
362 __begin_ = __c.__begin_;
365 __c.__first_ = nullptr;
366 __c.__begin_ = nullptr;
367 __c.__end_ = nullptr;
368 __c.__cap_ = nullptr;
370 auto __allocation = std::__allocate_at_least(__alloc_, __c.size());
371 __first_ = __allocation.ptr;
372 __begin_ = __end_ = __first_;
373 __cap_ = __first_ + __allocation.count;
374 typedef move_iterator<iterator> _Ip;
375 __construct_at_end(_Ip(__c.begin()), _Ip(__c.end()));
379 template <class _Tp, class _Allocator>
380 _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>&
381 __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
382 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
383 is_nothrow_move_assignable<allocator_type>::value) ||
384 !__alloc_traits::propagate_on_container_move_assignment::value) {
387 __first_ = __c.__first_;
388 __begin_ = __c.__begin_;
391 __move_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
392 __c.__first_ = __c.__begin_ = __c.__end_ = __c.__cap_ = nullptr;
396 template <class _Tp, class _Allocator>
397 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
398 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__alloc_rr>) {
399 std::swap(__first_, __x.__first_);
400 std::swap(__begin_, __x.__begin_);
401 std::swap(__end_, __x.__end_);
402 std::swap(__cap_, __x.__cap_);
403 std::__swap_allocator(__alloc_, __x.__alloc_);
406 template <class _Tp, class _Allocator>
407 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT {
408 if (capacity() > size()) {
409 #if _LIBCPP_HAS_EXCEPTIONS
411 #endif // _LIBCPP_HAS_EXCEPTIONS
412 __split_buffer<value_type, __alloc_rr&> __t(size(), 0, __alloc_);
413 if (__t.capacity() < capacity()) {
414 __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
415 __t.__end_ = __t.__begin_ + (__end_ - __begin_);
416 std::swap(__first_, __t.__first_);
417 std::swap(__begin_, __t.__begin_);
418 std::swap(__end_, __t.__end_);
419 std::swap(__cap_, __t.__cap_);
421 #if _LIBCPP_HAS_EXCEPTIONS
424 #endif // _LIBCPP_HAS_EXCEPTIONS
428 template <class _Tp, class _Allocator>
429 template <class... _Args>
430 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_front(_Args&&... __args) {
431 if (__begin_ == __first_) {
432 if (__end_ < __cap_) {
433 difference_type __d = __cap_ - __end_;
435 __begin_ = std::move_backward(__begin_, __end_, __end_ + __d);
438 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__cap_ - __first_), 1);
439 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc_);
440 __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
441 std::swap(__first_, __t.__first_);
442 std::swap(__begin_, __t.__begin_);
443 std::swap(__end_, __t.__end_);
444 std::swap(__cap_, __t.__cap_);
447 __alloc_traits::construct(__alloc_, std::__to_address(__begin_ - 1), std::forward<_Args>(__args)...);
451 template <class _Tp, class _Allocator>
452 template <class... _Args>
453 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) {
454 if (__end_ == __cap_) {
455 if (__begin_ > __first_) {
456 difference_type __d = __begin_ - __first_;
458 __end_ = std::move(__begin_, __end_, __begin_ - __d);
461 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__cap_ - __first_), 1);
462 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc_);
463 __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
464 std::swap(__first_, __t.__first_);
465 std::swap(__begin_, __t.__begin_);
466 std::swap(__end_, __t.__end_);
467 std::swap(__cap_, __t.__cap_);
470 __alloc_traits::construct(__alloc_, std::__to_address(__end_), std::forward<_Args>(__args)...);
474 template <class _Tp, class _Allocator>
475 _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void
476 swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
480 _LIBCPP_END_NAMESPACE_STD
484 #endif // _LIBCPP___SPLIT_BUFFER