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 //===----------------------------------------------------------------------===//
19 template <class T, class Alloc = allocator<T> >
26 typedef Alloc allocator_type;
27 typedef typename allocator_type::reference reference;
28 typedef typename allocator_type::const_reference const_reference;
29 typedef typename allocator_type::pointer pointer;
30 typedef typename allocator_type::const_pointer const_pointer;
31 typedef implementation-defined iterator;
32 typedef implementation-defined const_iterator;
33 typedef implementation-defined size_type;
34 typedef implementation-defined difference_type;
35 typedef reverse_iterator<iterator> reverse_iterator;
36 typedef reverse_iterator<const_iterator> const_reverse_iterator;
39 noexcept(is_nothrow_default_constructible<allocator_type>::value);
40 explicit list(const allocator_type& a);
41 explicit list(size_type n);
42 explicit list(size_type n, const allocator_type& a); // C++14
43 list(size_type n, const value_type& value);
44 list(size_type n, const value_type& value, const allocator_type& a);
46 list(Iter first, Iter last);
48 list(Iter first, Iter last, const allocator_type& a);
49 template<container-compatible-range<T> R>
50 list(from_range_t, R&& rg, const Allocator& = Allocator()); // C++23
52 list(const list&, const allocator_type& a);
54 noexcept(is_nothrow_move_constructible<allocator_type>::value);
55 list(list&&, const allocator_type& a);
56 list(initializer_list<value_type>);
57 list(initializer_list<value_type>, const allocator_type& a);
61 list& operator=(const list& x);
62 list& operator=(list&& x)
64 allocator_type::propagate_on_container_move_assignment::value &&
65 is_nothrow_move_assignable<allocator_type>::value);
66 list& operator=(initializer_list<value_type>);
68 void assign(Iter first, Iter last);
69 template<container-compatible-range<T> R>
70 void assign_range(R&& rg); // C++23
71 void assign(size_type n, const value_type& t);
72 void assign(initializer_list<value_type>);
74 allocator_type get_allocator() const noexcept;
76 iterator begin() noexcept;
77 const_iterator begin() const noexcept;
78 iterator end() noexcept;
79 const_iterator end() const noexcept;
80 reverse_iterator rbegin() noexcept;
81 const_reverse_iterator rbegin() const noexcept;
82 reverse_iterator rend() noexcept;
83 const_reverse_iterator rend() const noexcept;
84 const_iterator cbegin() const noexcept;
85 const_iterator cend() const noexcept;
86 const_reverse_iterator crbegin() const noexcept;
87 const_reverse_iterator crend() const noexcept;
90 const_reference front() const;
92 const_reference back() const;
94 bool empty() const noexcept;
95 size_type size() const noexcept;
96 size_type max_size() const noexcept;
98 template <class... Args>
99 reference emplace_front(Args&&... args); // reference in C++17
101 template <class... Args>
102 reference emplace_back(Args&&... args); // reference in C++17
104 void push_front(const value_type& x);
105 void push_front(value_type&& x);
106 template<container-compatible-range<T> R>
107 void prepend_range(R&& rg); // C++23
108 void push_back(const value_type& x);
109 void push_back(value_type&& x);
110 template<container-compatible-range<T> R>
111 void append_range(R&& rg); // C++23
112 template <class... Args>
113 iterator emplace(const_iterator position, Args&&... args);
114 iterator insert(const_iterator position, const value_type& x);
115 iterator insert(const_iterator position, value_type&& x);
116 iterator insert(const_iterator position, size_type n, const value_type& x);
117 template <class Iter>
118 iterator insert(const_iterator position, Iter first, Iter last);
119 template<container-compatible-range<T> R>
120 iterator insert_range(const_iterator position, R&& rg); // C++23
121 iterator insert(const_iterator position, initializer_list<value_type> il);
123 iterator erase(const_iterator position);
124 iterator erase(const_iterator position, const_iterator last);
126 void resize(size_type sz);
127 void resize(size_type sz, const value_type& c);
130 noexcept(allocator_traits<allocator_type>::is_always_equal::value); // C++17
131 void clear() noexcept;
133 void splice(const_iterator position, list& x);
134 void splice(const_iterator position, list&& x);
135 void splice(const_iterator position, list& x, const_iterator i);
136 void splice(const_iterator position, list&& x, const_iterator i);
137 void splice(const_iterator position, list& x, const_iterator first,
138 const_iterator last);
139 void splice(const_iterator position, list&& x, const_iterator first,
140 const_iterator last);
142 size_type remove(const value_type& value); // void before C++20
143 template <class Pred>
144 size_type remove_if(Pred pred); // void before C++20
145 size_type unique(); // void before C++20
146 template <class BinaryPredicate>
147 size_type unique(BinaryPredicate binary_pred); // void before C++20
149 void merge(list&& x);
150 template <class Compare>
151 void merge(list& x, Compare comp);
152 template <class Compare>
153 void merge(list&& x, Compare comp);
155 template <class Compare>
156 void sort(Compare comp);
157 void reverse() noexcept;
161 template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
162 list(InputIterator, InputIterator, Allocator = Allocator())
163 -> list<typename iterator_traits<InputIterator>::value_type, Allocator>; // C++17
165 template<ranges::input_range R, class Allocator = allocator<ranges::range_value_t<R>>>
166 list(from_range_t, R&&, Allocator = Allocator())
167 -> list<ranges::range_value_t<R>, Allocator>; // C++23
169 template <class T, class Alloc>
170 bool operator==(const list<T,Alloc>& x, const list<T,Alloc>& y);
171 template <class T, class Alloc>
172 bool operator< (const list<T,Alloc>& x, const list<T,Alloc>& y); // removed in C++20
173 template <class T, class Alloc>
174 bool operator!=(const list<T,Alloc>& x, const list<T,Alloc>& y); // removed in C++20
175 template <class T, class Alloc>
176 bool operator> (const list<T,Alloc>& x, const list<T,Alloc>& y); // removed in C++20
177 template <class T, class Alloc>
178 bool operator>=(const list<T,Alloc>& x, const list<T,Alloc>& y); // removed in C++20
179 template <class T, class Alloc>
180 bool operator<=(const list<T,Alloc>& x, const list<T,Alloc>& y); // removed in C++20
181 template<class T, class Allocator>
182 synth-three-way-result<T> operator<=>(const list<T, Allocator>& x,
183 const list<T, Allocator>& y); // since C++20
185 template <class T, class Alloc>
186 void swap(list<T,Alloc>& x, list<T,Alloc>& y)
187 noexcept(noexcept(x.swap(y)));
189 template <class T, class Allocator, class U>
190 typename list<T, Allocator>::size_type
191 erase(list<T, Allocator>& c, const U& value); // since C++20
192 template <class T, class Allocator, class Predicate>
193 typename list<T, Allocator>::size_type
194 erase_if(list<T, Allocator>& c, Predicate pred); // since C++20
200 #include <__algorithm/comp.h>
201 #include <__algorithm/equal.h>
202 #include <__algorithm/lexicographical_compare.h>
203 #include <__algorithm/lexicographical_compare_three_way.h>
204 #include <__algorithm/min.h>
207 #include <__format/enable_insertable.h>
208 #include <__iterator/distance.h>
209 #include <__iterator/iterator_traits.h>
210 #include <__iterator/move_iterator.h>
211 #include <__iterator/next.h>
212 #include <__iterator/prev.h>
213 #include <__iterator/reverse_iterator.h>
214 #include <__memory/addressof.h>
215 #include <__memory/allocation_guard.h>
216 #include <__memory/allocator.h>
217 #include <__memory/allocator_traits.h>
218 #include <__memory/compressed_pair.h>
219 #include <__memory/construct_at.h>
220 #include <__memory/pointer_traits.h>
221 #include <__memory/swap_allocator.h>
222 #include <__memory_resource/polymorphic_allocator.h>
223 #include <__ranges/access.h>
224 #include <__ranges/concepts.h>
225 #include <__ranges/container_compatible_range.h>
226 #include <__ranges/from_range.h>
227 #include <__type_traits/conditional.h>
228 #include <__type_traits/container_traits.h>
229 #include <__type_traits/enable_if.h>
230 #include <__type_traits/is_allocator.h>
231 #include <__type_traits/is_nothrow_assignable.h>
232 #include <__type_traits/is_nothrow_constructible.h>
233 #include <__type_traits/is_pointer.h>
234 #include <__type_traits/is_same.h>
235 #include <__type_traits/type_identity.h>
236 #include <__utility/forward.h>
237 #include <__utility/move.h>
238 #include <__utility/swap.h>
241 #include <new> // __launder
244 // standard-mandated includes
247 #include <__iterator/access.h>
248 #include <__iterator/data.h>
249 #include <__iterator/empty.h>
250 #include <__iterator/reverse_access.h>
251 #include <__iterator/size.h>
255 #include <initializer_list>
257 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
258 # pragma GCC system_header
262 #include <__undef_macros>
264 _LIBCPP_BEGIN_NAMESPACE_STD
266 template <class _Tp, class _VoidPtr>
268 template <class _Tp, class _VoidPtr>
269 struct __list_node_base;
271 template <class _Tp, class _VoidPtr>
272 struct __list_node_pointer_traits {
273 typedef __rebind_pointer_t<_VoidPtr, __list_node<_Tp, _VoidPtr> > __node_pointer;
274 typedef __rebind_pointer_t<_VoidPtr, __list_node_base<_Tp, _VoidPtr> > __base_pointer;
276 // TODO(LLVM 22): Remove this check
277 #ifndef _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
278 static_assert(sizeof(__node_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__base_pointer) ==
279 _LIBCPP_ALIGNOF(__node_pointer),
280 "It looks like you are using std::list with a fancy pointer type that thas a different representation "
281 "depending on whether it points to a list base pointer or a list node pointer (both of which are "
282 "implementation details of the standard library). This means that your ABI is being broken between "
283 "LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define the "
284 "_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic.");
287 static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__base_pointer __p) { return __p; }
289 static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__node_pointer __p) {
290 return static_cast<__base_pointer>(static_cast<_VoidPtr>(__p));
294 template <class _Tp, class _VoidPtr>
295 struct __list_node_base {
296 typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
297 typedef typename _NodeTraits::__node_pointer __node_pointer;
298 typedef typename _NodeTraits::__base_pointer __base_pointer;
300 __base_pointer __prev_;
301 __base_pointer __next_;
303 _LIBCPP_HIDE_FROM_ABI __list_node_base() : __prev_(__self()), __next_(__self()) {}
305 _LIBCPP_HIDE_FROM_ABI explicit __list_node_base(__base_pointer __prev, __base_pointer __next)
306 : __prev_(__prev), __next_(__next) {}
308 _LIBCPP_HIDE_FROM_ABI __base_pointer __self() { return pointer_traits<__base_pointer>::pointer_to(*this); }
310 _LIBCPP_HIDE_FROM_ABI __node_pointer __as_node() { return static_cast<__node_pointer>(__self()); }
313 template <class _Tp, class _VoidPtr>
314 struct __list_node : public __list_node_base<_Tp, _VoidPtr> {
315 // We allow starting the lifetime of nodes without initializing the value held by the node,
316 // since that is handled by the list itself in order to be allocator-aware.
317 #ifndef _LIBCPP_CXX03_LANG
325 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }
329 _ALIGNAS_TYPE(_Tp) char __buffer_[sizeof(_Tp)];
332 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); }
335 typedef __list_node_base<_Tp, _VoidPtr> __base;
336 typedef typename __base::__base_pointer __base_pointer;
338 _LIBCPP_HIDE_FROM_ABI explicit __list_node(__base_pointer __prev, __base_pointer __next) : __base(__prev, __next) {}
339 _LIBCPP_HIDE_FROM_ABI ~__list_node() {}
341 _LIBCPP_HIDE_FROM_ABI __base_pointer __as_link() { return __base::__self(); }
344 template <class _Tp, class _Alloc = allocator<_Tp> >
345 class _LIBCPP_TEMPLATE_VIS list;
346 template <class _Tp, class _Alloc>
348 template <class _Tp, class _VoidPtr>
349 class _LIBCPP_TEMPLATE_VIS __list_const_iterator;
351 template <class _Tp, class _VoidPtr>
352 class _LIBCPP_TEMPLATE_VIS __list_iterator {
353 typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
354 typedef typename _NodeTraits::__base_pointer __base_pointer;
356 __base_pointer __ptr_;
358 _LIBCPP_HIDE_FROM_ABI explicit __list_iterator(__base_pointer __p) _NOEXCEPT : __ptr_(__p) {}
360 template <class, class>
362 template <class, class>
363 friend class __list_imp;
364 template <class, class>
365 friend class __list_const_iterator;
368 typedef bidirectional_iterator_tag iterator_category;
369 typedef _Tp value_type;
370 typedef value_type& reference;
371 typedef __rebind_pointer_t<_VoidPtr, value_type> pointer;
372 typedef typename pointer_traits<pointer>::difference_type difference_type;
374 _LIBCPP_HIDE_FROM_ABI __list_iterator() _NOEXCEPT : __ptr_(nullptr) {}
376 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __ptr_->__as_node()->__get_value(); }
377 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
378 return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__get_value());
381 _LIBCPP_HIDE_FROM_ABI __list_iterator& operator++() {
382 __ptr_ = __ptr_->__next_;
385 _LIBCPP_HIDE_FROM_ABI __list_iterator operator++(int) {
386 __list_iterator __t(*this);
391 _LIBCPP_HIDE_FROM_ABI __list_iterator& operator--() {
392 __ptr_ = __ptr_->__prev_;
395 _LIBCPP_HIDE_FROM_ABI __list_iterator operator--(int) {
396 __list_iterator __t(*this);
401 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __list_iterator& __x, const __list_iterator& __y) {
402 return __x.__ptr_ == __y.__ptr_;
404 friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __list_iterator& __x, const __list_iterator& __y) {
405 return !(__x == __y);
409 template <class _Tp, class _VoidPtr>
410 class _LIBCPP_TEMPLATE_VIS __list_const_iterator {
411 typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
412 typedef typename _NodeTraits::__base_pointer __base_pointer;
414 __base_pointer __ptr_;
416 _LIBCPP_HIDE_FROM_ABI explicit __list_const_iterator(__base_pointer __p) _NOEXCEPT : __ptr_(__p) {}
418 template <class, class>
420 template <class, class>
421 friend class __list_imp;
424 typedef bidirectional_iterator_tag iterator_category;
425 typedef _Tp value_type;
426 typedef const value_type& reference;
427 typedef __rebind_pointer_t<_VoidPtr, const value_type> pointer;
428 typedef typename pointer_traits<pointer>::difference_type difference_type;
430 _LIBCPP_HIDE_FROM_ABI __list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {}
431 _LIBCPP_HIDE_FROM_ABI __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT
432 : __ptr_(__p.__ptr_) {}
434 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __ptr_->__as_node()->__get_value(); }
435 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
436 return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__get_value());
439 _LIBCPP_HIDE_FROM_ABI __list_const_iterator& operator++() {
440 __ptr_ = __ptr_->__next_;
443 _LIBCPP_HIDE_FROM_ABI __list_const_iterator operator++(int) {
444 __list_const_iterator __t(*this);
449 _LIBCPP_HIDE_FROM_ABI __list_const_iterator& operator--() {
450 __ptr_ = __ptr_->__prev_;
453 _LIBCPP_HIDE_FROM_ABI __list_const_iterator operator--(int) {
454 __list_const_iterator __t(*this);
459 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __list_const_iterator& __x, const __list_const_iterator& __y) {
460 return __x.__ptr_ == __y.__ptr_;
462 friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __list_const_iterator& __x, const __list_const_iterator& __y) {
463 return !(__x == __y);
467 template <class _Tp, class _Alloc>
470 __list_imp(const __list_imp&) = delete;
471 __list_imp& operator=(const __list_imp&) = delete;
473 typedef _Alloc allocator_type;
474 typedef allocator_traits<allocator_type> __alloc_traits;
475 typedef typename __alloc_traits::size_type size_type;
478 typedef _Tp value_type;
479 typedef typename __alloc_traits::void_pointer __void_pointer;
480 typedef __list_iterator<value_type, __void_pointer> iterator;
481 typedef __list_const_iterator<value_type, __void_pointer> const_iterator;
482 typedef __list_node_base<value_type, __void_pointer> __node_base;
483 typedef __list_node<value_type, __void_pointer> __node_type;
484 typedef __rebind_alloc<__alloc_traits, __node_type> __node_allocator;
485 typedef allocator_traits<__node_allocator> __node_alloc_traits;
486 typedef typename __node_alloc_traits::pointer __node_pointer;
487 typedef typename __node_alloc_traits::pointer __node_const_pointer;
488 typedef __list_node_pointer_traits<value_type, __void_pointer> __node_pointer_traits;
489 typedef typename __node_pointer_traits::__base_pointer __base_pointer;
490 typedef __base_pointer __link_const_pointer;
491 typedef typename __alloc_traits::pointer pointer;
492 typedef typename __alloc_traits::const_pointer const_pointer;
493 typedef typename __alloc_traits::difference_type difference_type;
495 typedef __rebind_alloc<__alloc_traits, __node_base> __node_base_allocator;
496 typedef typename allocator_traits<__node_base_allocator>::pointer __node_base_pointer;
497 static_assert(!is_same<allocator_type, __node_allocator>::value,
498 "internal allocator type must differ from user-specified type; otherwise overload resolution breaks");
501 _LIBCPP_COMPRESSED_PAIR(size_type, __size_, __node_allocator, __node_alloc_);
503 _LIBCPP_HIDE_FROM_ABI __base_pointer __end_as_link() const _NOEXCEPT {
504 return __node_pointer_traits::__unsafe_link_pointer_cast(const_cast<__node_base&>(__end_).__self());
507 _LIBCPP_HIDE_FROM_ABI size_type __node_alloc_max_size() const _NOEXCEPT {
508 return __node_alloc_traits::max_size(__node_alloc_);
510 _LIBCPP_HIDE_FROM_ABI static void __unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT;
512 _LIBCPP_HIDE_FROM_ABI __list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value);
513 _LIBCPP_HIDE_FROM_ABI __list_imp(const allocator_type& __a);
514 _LIBCPP_HIDE_FROM_ABI __list_imp(const __node_allocator& __a);
515 #ifndef _LIBCPP_CXX03_LANG
516 _LIBCPP_HIDE_FROM_ABI __list_imp(__node_allocator&& __a) _NOEXCEPT;
518 _LIBCPP_HIDE_FROM_ABI ~__list_imp();
519 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;
520 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __size_ == 0; }
522 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__end_.__next_); }
523 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(__end_.__next_); }
524 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(__end_as_link()); }
525 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(__end_as_link()); }
527 _LIBCPP_HIDE_FROM_ABI void swap(__list_imp& __c)
528 #if _LIBCPP_STD_VER >= 14
531 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
534 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c) {
536 __c, integral_constant<bool, __node_alloc_traits::propagate_on_container_copy_assignment::value>());
539 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c)
540 _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_move_assignment::value ||
541 is_nothrow_move_assignable<__node_allocator>::value) {
543 __c, integral_constant<bool, __node_alloc_traits::propagate_on_container_move_assignment::value>());
546 template <class... _Args>
547 _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__base_pointer __prev, __base_pointer __next, _Args&&... __args) {
548 __allocation_guard<__node_allocator> __guard(__node_alloc_, 1);
549 // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value
550 // held inside the node, since we need to use the allocator's construct() method for that.
552 // We don't use the allocator's construct() method to construct the node itself since the
553 // Cpp17FooInsertable named requirements don't require the allocator's construct() method
554 // to work on anything other than the value_type.
555 std::__construct_at(std::addressof(*__guard.__get()), __prev, __next);
557 // Now construct the value_type using the allocator's construct() method.
558 __node_alloc_traits::construct(
559 __node_alloc_, std::addressof(__guard.__get()->__get_value()), std::forward<_Args>(__args)...);
560 return __guard.__release_ptr();
563 _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) {
564 // For the same reason as above, we use the allocator's destroy() method for the value_type,
565 // but not for the node itself.
566 __node_alloc_traits::destroy(__node_alloc_, std::addressof(__node->__get_value()));
567 std::__destroy_at(std::addressof(*__node));
568 __node_alloc_traits::deallocate(__node_alloc_, __node, 1);
572 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c, true_type) {
573 if (__node_alloc_ != __c.__node_alloc_)
575 __node_alloc_ = __c.__node_alloc_;
578 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp&, false_type) {}
580 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c, true_type)
581 _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {
582 __node_alloc_ = std::move(__c.__node_alloc_);
585 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp&, false_type) _NOEXCEPT {}
588 // Unlink nodes [__f, __l]
589 template <class _Tp, class _Alloc>
590 inline void __list_imp<_Tp, _Alloc>::__unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT {
591 __f->__prev_->__next_ = __l->__next_;
592 __l->__next_->__prev_ = __f->__prev_;
595 template <class _Tp, class _Alloc>
596 inline __list_imp<_Tp, _Alloc>::__list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
599 template <class _Tp, class _Alloc>
600 inline __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a)
601 : __size_(0), __node_alloc_(__node_allocator(__a)) {}
603 template <class _Tp, class _Alloc>
604 inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a) : __size_(0), __node_alloc_(__a) {}
606 #ifndef _LIBCPP_CXX03_LANG
607 template <class _Tp, class _Alloc>
608 inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT
610 __node_alloc_(std::move(__a)) {}
613 template <class _Tp, class _Alloc>
614 __list_imp<_Tp, _Alloc>::~__list_imp() {
618 template <class _Tp, class _Alloc>
619 void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT {
621 __base_pointer __f = __end_.__next_;
622 __base_pointer __l = __end_as_link();
623 __unlink_nodes(__f, __l->__prev_);
626 __node_pointer __np = __f->__as_node();
633 template <class _Tp, class _Alloc>
634 void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
635 #if _LIBCPP_STD_VER >= 14
638 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)
641 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
642 __alloc_traits::propagate_on_container_swap::value || this->__node_alloc_ == __c.__node_alloc_,
643 "list::swap: Either propagate_on_container_swap must be true"
644 " or the allocators must compare equal");
646 std::__swap_allocator(__node_alloc_, __c.__node_alloc_);
647 swap(__size_, __c.__size_);
648 swap(__end_, __c.__end_);
650 __end_.__next_ = __end_.__prev_ = __end_as_link();
652 __end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_as_link();
653 if (__c.__size_ == 0)
654 __c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_as_link();
656 __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link();
659 template <class _Tp, class _Alloc /*= allocator<_Tp>*/>
660 class _LIBCPP_TEMPLATE_VIS list : private __list_imp<_Tp, _Alloc> {
661 typedef __list_imp<_Tp, _Alloc> __base;
662 typedef typename __base::__node_type __node_type;
663 typedef typename __base::__node_allocator __node_allocator;
664 typedef typename __base::__node_pointer __node_pointer;
665 typedef typename __base::__node_alloc_traits __node_alloc_traits;
666 typedef typename __base::__node_base __node_base;
667 typedef typename __base::__node_base_pointer __node_base_pointer;
668 typedef typename __base::__base_pointer __base_pointer;
671 typedef _Tp value_type;
672 typedef _Alloc allocator_type;
673 static_assert(__check_valid_allocator<allocator_type>::value);
674 static_assert(is_same<value_type, typename allocator_type::value_type>::value,
675 "Allocator::value_type must be same type as value_type");
676 typedef value_type& reference;
677 typedef const value_type& const_reference;
678 typedef typename __base::pointer pointer;
679 typedef typename __base::const_pointer const_pointer;
680 typedef typename __base::size_type size_type;
681 typedef typename __base::difference_type difference_type;
682 typedef typename __base::iterator iterator;
683 typedef typename __base::const_iterator const_iterator;
684 typedef std::reverse_iterator<iterator> reverse_iterator;
685 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
686 #if _LIBCPP_STD_VER >= 20
687 typedef size_type __remove_return_type;
689 typedef void __remove_return_type;
692 _LIBCPP_HIDE_FROM_ABI list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {}
693 _LIBCPP_HIDE_FROM_ABI explicit list(const allocator_type& __a) : __base(__a) {}
694 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n);
695 #if _LIBCPP_STD_VER >= 14
696 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a);
698 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x);
699 template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
700 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x, const allocator_type& __a) : __base(__a) {
701 for (; __n > 0; --__n)
705 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
706 _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l);
708 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
709 _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l, const allocator_type& __a);
711 #if _LIBCPP_STD_VER >= 23
712 template <_ContainerCompatibleRange<_Tp> _Range>
713 _LIBCPP_HIDE_FROM_ABI list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())
715 prepend_range(std::forward<_Range>(__range));
719 _LIBCPP_HIDE_FROM_ABI list(const list& __c);
720 _LIBCPP_HIDE_FROM_ABI list(const list& __c, const __type_identity_t<allocator_type>& __a);
721 _LIBCPP_HIDE_FROM_ABI list& operator=(const list& __c);
722 #ifndef _LIBCPP_CXX03_LANG
723 _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il);
724 _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il, const allocator_type& __a);
726 _LIBCPP_HIDE_FROM_ABI list(list&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
727 _LIBCPP_HIDE_FROM_ABI list(list&& __c, const __type_identity_t<allocator_type>& __a);
728 _LIBCPP_HIDE_FROM_ABI list& operator=(list&& __c)
729 _NOEXCEPT_(__node_alloc_traits::propagate_on_container_move_assignment::value&&
730 is_nothrow_move_assignable<__node_allocator>::value);
732 _LIBCPP_HIDE_FROM_ABI list& operator=(initializer_list<value_type> __il) {
733 assign(__il.begin(), __il.end());
737 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); }
738 #endif // _LIBCPP_CXX03_LANG
740 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
741 _LIBCPP_HIDE_FROM_ABI void assign(_InpIter __f, _InpIter __l);
743 #if _LIBCPP_STD_VER >= 23
744 template <_ContainerCompatibleRange<_Tp> _Range>
745 _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) {
746 __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));
750 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __x);
752 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT;
754 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return this->__size_; }
755 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __base::empty(); }
756 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
757 return std::min<size_type>(this->__node_alloc_max_size(), numeric_limits<difference_type >::max());
760 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __base::begin(); }
761 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __base::begin(); }
762 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __base::end(); }
763 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __base::end(); }
764 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __base::begin(); }
765 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __base::end(); }
767 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); }
768 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); }
769 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); }
770 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); }
771 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(end()); }
772 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(begin()); }
774 _LIBCPP_HIDE_FROM_ABI reference front() {
775 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list");
776 return __base::__end_.__next_->__as_node()->__get_value();
778 _LIBCPP_HIDE_FROM_ABI const_reference front() const {
779 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list");
780 return __base::__end_.__next_->__as_node()->__get_value();
782 _LIBCPP_HIDE_FROM_ABI reference back() {
783 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list");
784 return __base::__end_.__prev_->__as_node()->__get_value();
786 _LIBCPP_HIDE_FROM_ABI const_reference back() const {
787 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list");
788 return __base::__end_.__prev_->__as_node()->__get_value();
791 #ifndef _LIBCPP_CXX03_LANG
792 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x);
793 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);
795 # if _LIBCPP_STD_VER >= 23
796 template <_ContainerCompatibleRange<_Tp> _Range>
797 _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) {
798 insert_range(begin(), std::forward<_Range>(__range));
801 template <_ContainerCompatibleRange<_Tp> _Range>
802 _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) {
803 insert_range(end(), std::forward<_Range>(__range));
807 template <class... _Args>
808 # if _LIBCPP_STD_VER >= 17
809 _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args);
811 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);
813 template <class... _Args>
814 # if _LIBCPP_STD_VER >= 17
815 _LIBCPP_HIDE_FROM_ABI reference emplace_back(_Args&&... __args);
817 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args);
819 template <class... _Args>
820 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args);
822 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x);
824 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, initializer_list<value_type> __il) {
825 return insert(__p, __il.begin(), __il.end());
827 #endif // _LIBCPP_CXX03_LANG
829 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __x);
830 _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __x);
832 #ifndef _LIBCPP_CXX03_LANG
833 template <class _Arg>
834 _LIBCPP_HIDE_FROM_ABI void __emplace_back(_Arg&& __arg) {
835 emplace_back(std::forward<_Arg>(__arg));
838 _LIBCPP_HIDE_FROM_ABI void __emplace_back(value_type const& __arg) { push_back(__arg); }
841 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x);
842 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __x);
844 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
845 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InpIter __f, _InpIter __l);
847 #if _LIBCPP_STD_VER >= 23
848 template <_ContainerCompatibleRange<_Tp> _Range>
849 _LIBCPP_HIDE_FROM_ABI iterator insert_range(const_iterator __position, _Range&& __range) {
850 return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));
854 _LIBCPP_HIDE_FROM_ABI void swap(list& __c)
855 #if _LIBCPP_STD_VER >= 14
858 _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)
863 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __base::clear(); }
865 _LIBCPP_HIDE_FROM_ABI void pop_front();
866 _LIBCPP_HIDE_FROM_ABI void pop_back();
868 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p);
869 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l);
871 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n);
872 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __x);
874 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c);
875 #ifndef _LIBCPP_CXX03_LANG
876 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c) { splice(__p, __c); }
877 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __i) { splice(__p, __c, __i); }
878 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __f, const_iterator __l) {
879 splice(__p, __c, __f, __l);
882 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __i);
883 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l);
885 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove(const value_type& __x);
886 template <class _Pred>
887 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove_if(_Pred __pred);
888 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique() { return unique(__equal_to()); }
889 template <class _BinaryPred>
890 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPred __binary_pred);
891 _LIBCPP_HIDE_FROM_ABI void merge(list& __c);
892 #ifndef _LIBCPP_CXX03_LANG
893 _LIBCPP_HIDE_FROM_ABI void merge(list&& __c) { merge(__c); }
895 template <class _Comp>
896 _LIBCPP_HIDE_FROM_ABI void merge(list&& __c, _Comp __comp) {
900 template <class _Comp>
901 _LIBCPP_HIDE_FROM_ABI void merge(list& __c, _Comp __comp);
903 _LIBCPP_HIDE_FROM_ABI void sort();
904 template <class _Comp>
905 _LIBCPP_HIDE_FROM_ABI void sort(_Comp __comp);
907 _LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT;
909 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
912 template <class _Iterator, class _Sentinel>
913 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __f, _Sentinel __l);
915 template <class _Iterator, class _Sentinel>
916 _LIBCPP_HIDE_FROM_ABI iterator __insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l);
918 _LIBCPP_HIDE_FROM_ABI static void __link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l);
919 _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_front(__base_pointer __f, __base_pointer __l);
920 _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_back(__base_pointer __f, __base_pointer __l);
921 _LIBCPP_HIDE_FROM_ABI iterator __iterator(size_type __n);
922 // TODO: Make this _LIBCPP_HIDE_FROM_ABI
923 template <class _Comp>
924 _LIBCPP_HIDDEN static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp);
926 _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, true_type)
927 _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value);
928 _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, false_type);
931 #if _LIBCPP_STD_VER >= 17
932 template <class _InputIterator,
933 class _Alloc = allocator<__iter_value_type<_InputIterator>>,
934 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
935 class = enable_if_t<__is_allocator<_Alloc>::value> >
936 list(_InputIterator, _InputIterator) -> list<__iter_value_type<_InputIterator>, _Alloc>;
938 template <class _InputIterator,
940 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
941 class = enable_if_t<__is_allocator<_Alloc>::value> >
942 list(_InputIterator, _InputIterator, _Alloc) -> list<__iter_value_type<_InputIterator>, _Alloc>;
945 #if _LIBCPP_STD_VER >= 23
946 template <ranges::input_range _Range,
947 class _Alloc = allocator<ranges::range_value_t<_Range>>,
948 class = enable_if_t<__is_allocator<_Alloc>::value> >
949 list(from_range_t, _Range&&, _Alloc = _Alloc()) -> list<ranges::range_value_t<_Range>, _Alloc>;
952 // Link in nodes [__f, __l] just prior to __p
953 template <class _Tp, class _Alloc>
954 inline void list<_Tp, _Alloc>::__link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l) {
955 __p->__prev_->__next_ = __f;
956 __f->__prev_ = __p->__prev_;
961 // Link in nodes [__f, __l] at the front of the list
962 template <class _Tp, class _Alloc>
963 inline void list<_Tp, _Alloc>::__link_nodes_at_front(__base_pointer __f, __base_pointer __l) {
964 __f->__prev_ = __base::__end_as_link();
965 __l->__next_ = __base::__end_.__next_;
966 __l->__next_->__prev_ = __l;
967 __base::__end_.__next_ = __f;
970 // Link in nodes [__f, __l] at the back of the list
971 template <class _Tp, class _Alloc>
972 inline void list<_Tp, _Alloc>::__link_nodes_at_back(__base_pointer __f, __base_pointer __l) {
973 __l->__next_ = __base::__end_as_link();
974 __f->__prev_ = __base::__end_.__prev_;
975 __f->__prev_->__next_ = __f;
976 __base::__end_.__prev_ = __l;
979 template <class _Tp, class _Alloc>
980 inline typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::__iterator(size_type __n) {
981 return __n <= this->__size_ / 2 ? std::next(begin(), __n) : std::prev(end(), this->__size_ - __n);
984 template <class _Tp, class _Alloc>
985 list<_Tp, _Alloc>::list(size_type __n) {
986 for (; __n > 0; --__n)
987 #ifndef _LIBCPP_CXX03_LANG
990 push_back(value_type());
994 #if _LIBCPP_STD_VER >= 14
995 template <class _Tp, class _Alloc>
996 list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : __base(__a) {
997 for (; __n > 0; --__n)
1002 template <class _Tp, class _Alloc>
1003 list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) {
1004 for (; __n > 0; --__n)
1008 template <class _Tp, class _Alloc>
1009 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
1010 list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l) {
1011 for (; __f != __l; ++__f)
1012 __emplace_back(*__f);
1015 template <class _Tp, class _Alloc>
1016 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
1017 list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a) : __base(__a) {
1018 for (; __f != __l; ++__f)
1019 __emplace_back(*__f);
1022 template <class _Tp, class _Alloc>
1023 list<_Tp, _Alloc>::list(const list& __c)
1024 : __base(__node_alloc_traits::select_on_container_copy_construction(__c.__node_alloc_)) {
1025 for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
1029 template <class _Tp, class _Alloc>
1030 list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>& __a) : __base(__a) {
1031 for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
1035 #ifndef _LIBCPP_CXX03_LANG
1037 template <class _Tp, class _Alloc>
1038 list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a) : __base(__a) {
1039 for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), __e = __il.end(); __i != __e; ++__i)
1043 template <class _Tp, class _Alloc>
1044 list<_Tp, _Alloc>::list(initializer_list<value_type> __il) {
1045 for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), __e = __il.end(); __i != __e; ++__i)
1049 template <class _Tp, class _Alloc>
1050 inline list<_Tp, _Alloc>::list(list&& __c) noexcept(is_nothrow_move_constructible<__node_allocator>::value)
1051 : __base(std::move(__c.__node_alloc_)) {
1055 template <class _Tp, class _Alloc>
1056 inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_type>& __a) : __base(__a) {
1057 if (__a == __c.get_allocator())
1060 typedef move_iterator<iterator> _Ip;
1061 assign(_Ip(__c.begin()), _Ip(__c.end()));
1065 template <class _Tp, class _Alloc>
1066 inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c) noexcept(
1067 __node_alloc_traits::propagate_on_container_move_assignment::value &&
1068 is_nothrow_move_assignable<__node_allocator>::value) {
1069 __move_assign(__c, integral_constant<bool, __node_alloc_traits::propagate_on_container_move_assignment::value>());
1073 template <class _Tp, class _Alloc>
1074 void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) {
1075 if (this->__node_alloc_ != __c.__node_alloc_) {
1076 typedef move_iterator<iterator> _Ip;
1077 assign(_Ip(__c.begin()), _Ip(__c.end()));
1079 __move_assign(__c, true_type());
1082 template <class _Tp, class _Alloc>
1083 void list<_Tp, _Alloc>::__move_assign(list& __c,
1084 true_type) noexcept(is_nothrow_move_assignable<__node_allocator>::value) {
1086 __base::__move_assign_alloc(__c);
1090 #endif // _LIBCPP_CXX03_LANG
1092 template <class _Tp, class _Alloc>
1093 inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) {
1094 if (this != std::addressof(__c)) {
1095 __base::__copy_assign_alloc(__c);
1096 assign(__c.begin(), __c.end());
1101 template <class _Tp, class _Alloc>
1102 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
1103 void list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l) {
1104 __assign_with_sentinel(__f, __l);
1107 template <class _Tp, class _Alloc>
1108 template <class _Iterator, class _Sentinel>
1109 _LIBCPP_HIDE_FROM_ABI void list<_Tp, _Alloc>::__assign_with_sentinel(_Iterator __f, _Sentinel __l) {
1110 iterator __i = begin();
1111 iterator __e = end();
1112 for (; __f != __l && __i != __e; ++__f, (void)++__i)
1115 __insert_with_sentinel(__e, std::move(__f), std::move(__l));
1120 template <class _Tp, class _Alloc>
1121 void list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) {
1122 iterator __i = begin();
1123 iterator __e = end();
1124 for (; __n > 0 && __i != __e; --__n, (void)++__i)
1127 insert(__e, __n, __x);
1132 template <class _Tp, class _Alloc>
1133 inline _Alloc list<_Tp, _Alloc>::get_allocator() const _NOEXCEPT {
1134 return allocator_type(this->__node_alloc_);
1137 template <class _Tp, class _Alloc>
1138 typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) {
1139 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);
1140 __link_nodes(__p.__ptr_, __node->__as_link(), __node->__as_link());
1142 return iterator(__node->__as_link());
1145 template <class _Tp, class _Alloc>
1146 typename list<_Tp, _Alloc>::iterator
1147 list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& __x) {
1148 iterator __r(__p.__ptr_);
1151 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);
1153 __r = iterator(__node->__as_link());
1155 #if _LIBCPP_HAS_EXCEPTIONS
1157 #endif // _LIBCPP_HAS_EXCEPTIONS
1158 for (--__n; __n != 0; --__n, (void)++__e, ++__ds) {
1159 __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link();
1161 #if _LIBCPP_HAS_EXCEPTIONS
1164 __base_pointer __prev = __e.__ptr_->__prev_;
1165 __node_pointer __current = __e.__ptr_->__as_node();
1166 this->__delete_node(__current);
1169 __e = iterator(__prev);
1173 #endif // _LIBCPP_HAS_EXCEPTIONS
1174 __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
1175 this->__size_ += __ds;
1180 template <class _Tp, class _Alloc>
1181 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
1182 typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l) {
1183 return __insert_with_sentinel(__p, __f, __l);
1186 template <class _Tp, class _Alloc>
1187 template <class _Iterator, class _Sentinel>
1188 _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Alloc>::iterator
1189 list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l) {
1190 iterator __r(__p.__ptr_);
1193 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, *__f);
1195 __r = iterator(__node->__as_link());
1197 #if _LIBCPP_HAS_EXCEPTIONS
1199 #endif // _LIBCPP_HAS_EXCEPTIONS
1200 for (++__f; __f != __l; ++__f, (void)++__e, ++__ds) {
1201 __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, *__f)->__as_link();
1203 #if _LIBCPP_HAS_EXCEPTIONS
1206 __base_pointer __prev = __e.__ptr_->__prev_;
1207 __node_pointer __current = __e.__ptr_->__as_node();
1208 this->__delete_node(__current);
1211 __e = iterator(__prev);
1215 #endif // _LIBCPP_HAS_EXCEPTIONS
1216 __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
1217 this->__size_ += __ds;
1222 template <class _Tp, class _Alloc>
1223 void list<_Tp, _Alloc>::push_front(const value_type& __x) {
1224 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);
1225 __base_pointer __nl = __node->__as_link();
1226 __link_nodes_at_front(__nl, __nl);
1230 template <class _Tp, class _Alloc>
1231 void list<_Tp, _Alloc>::push_back(const value_type& __x) {
1232 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);
1233 __base_pointer __nl = __node->__as_link();
1234 __link_nodes_at_back(__nl, __nl);
1238 #ifndef _LIBCPP_CXX03_LANG
1240 template <class _Tp, class _Alloc>
1241 void list<_Tp, _Alloc>::push_front(value_type&& __x) {
1242 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));
1243 __base_pointer __nl = __node->__as_link();
1244 __link_nodes_at_front(__nl, __nl);
1248 template <class _Tp, class _Alloc>
1249 void list<_Tp, _Alloc>::push_back(value_type&& __x) {
1250 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));
1251 __base_pointer __nl = __node->__as_link();
1252 __link_nodes_at_back(__nl, __nl);
1256 template <class _Tp, class _Alloc>
1257 template <class... _Args>
1258 # if _LIBCPP_STD_VER >= 17
1259 typename list<_Tp, _Alloc>::reference
1263 list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {
1264 __node_pointer __node =
1265 this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);
1266 __base_pointer __nl = __node->__as_link();
1267 __link_nodes_at_front(__nl, __nl);
1269 # if _LIBCPP_STD_VER >= 17
1270 return __node->__get_value();
1274 template <class _Tp, class _Alloc>
1275 template <class... _Args>
1276 # if _LIBCPP_STD_VER >= 17
1277 typename list<_Tp, _Alloc>::reference
1281 list<_Tp, _Alloc>::emplace_back(_Args&&... __args) {
1282 __node_pointer __node =
1283 this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);
1284 __base_pointer __nl = __node->__as_link();
1285 __link_nodes_at_back(__nl, __nl);
1287 # if _LIBCPP_STD_VER >= 17
1288 return __node->__get_value();
1292 template <class _Tp, class _Alloc>
1293 template <class... _Args>
1294 typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) {
1295 __node_pointer __node =
1296 this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);
1297 __base_pointer __nl = __node->__as_link();
1298 __link_nodes(__p.__ptr_, __nl, __nl);
1300 return iterator(__nl);
1303 template <class _Tp, class _Alloc>
1304 typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) {
1305 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));
1306 __base_pointer __nl = __node->__as_link();
1307 __link_nodes(__p.__ptr_, __nl, __nl);
1309 return iterator(__nl);
1312 #endif // _LIBCPP_CXX03_LANG
1314 template <class _Tp, class _Alloc>
1315 void list<_Tp, _Alloc>::pop_front() {
1316 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_front() called with empty list");
1317 __base_pointer __n = __base::__end_.__next_;
1318 __base::__unlink_nodes(__n, __n);
1320 this->__delete_node(__n->__as_node());
1323 template <class _Tp, class _Alloc>
1324 void list<_Tp, _Alloc>::pop_back() {
1325 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_back() called on an empty list");
1326 __base_pointer __n = __base::__end_.__prev_;
1327 __base::__unlink_nodes(__n, __n);
1329 this->__delete_node(__n->__as_node());
1332 template <class _Tp, class _Alloc>
1333 typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p) {
1334 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p != end(), "list::erase(iterator) called with a non-dereferenceable iterator");
1335 __base_pointer __n = __p.__ptr_;
1336 __base_pointer __r = __n->__next_;
1337 __base::__unlink_nodes(__n, __n);
1339 this->__delete_node(__n->__as_node());
1340 return iterator(__r);
1343 template <class _Tp, class _Alloc>
1344 typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) {
1346 __base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_);
1347 while (__f != __l) {
1348 __base_pointer __n = __f.__ptr_;
1351 this->__delete_node(__n->__as_node());
1354 return iterator(__l.__ptr_);
1357 template <class _Tp, class _Alloc>
1358 void list<_Tp, _Alloc>::resize(size_type __n) {
1359 if (__n < this->__size_)
1360 erase(__iterator(__n), end());
1361 else if (__n > this->__size_) {
1362 __n -= this->__size_;
1364 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr);
1366 iterator __r = iterator(__node->__as_link());
1368 #if _LIBCPP_HAS_EXCEPTIONS
1370 #endif // _LIBCPP_HAS_EXCEPTIONS
1371 for (--__n; __n != 0; --__n, (void)++__e, ++__ds) {
1372 __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr)->__as_link();
1374 #if _LIBCPP_HAS_EXCEPTIONS
1377 __base_pointer __prev = __e.__ptr_->__prev_;
1378 __node_pointer __current = __e.__ptr_->__as_node();
1379 this->__delete_node(__current);
1382 __e = iterator(__prev);
1386 #endif // _LIBCPP_HAS_EXCEPTIONS
1387 __link_nodes_at_back(__r.__ptr_, __e.__ptr_);
1388 this->__size_ += __ds;
1392 template <class _Tp, class _Alloc>
1393 void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) {
1394 if (__n < this->__size_)
1395 erase(__iterator(__n), end());
1396 else if (__n > this->__size_) {
1397 __n -= this->__size_;
1399 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);
1401 __base_pointer __nl = __node->__as_link();
1402 iterator __r = iterator(__nl);
1404 #if _LIBCPP_HAS_EXCEPTIONS
1406 #endif // _LIBCPP_HAS_EXCEPTIONS
1407 for (--__n; __n != 0; --__n, (void)++__e, ++__ds) {
1408 __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link();
1410 #if _LIBCPP_HAS_EXCEPTIONS
1413 __base_pointer __prev = __e.__ptr_->__prev_;
1414 __node_pointer __current = __e.__ptr_->__as_node();
1415 this->__delete_node(__current);
1418 __e = iterator(__prev);
1422 #endif // _LIBCPP_HAS_EXCEPTIONS
1423 __link_nodes(__base::__end_as_link(), __r.__ptr_, __e.__ptr_);
1424 this->__size_ += __ds;
1428 template <class _Tp, class _Alloc>
1429 void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) {
1430 _LIBCPP_ASSERT_VALID_INPUT_RANGE(
1431 this != std::addressof(__c), "list::splice(iterator, list) called with this == &list");
1433 __base_pointer __f = __c.__end_.__next_;
1434 __base_pointer __l = __c.__end_.__prev_;
1435 __base::__unlink_nodes(__f, __l);
1436 __link_nodes(__p.__ptr_, __f, __l);
1437 this->__size_ += __c.__size_;
1442 template <class _Tp, class _Alloc>
1443 void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) {
1444 if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_) {
1445 __base_pointer __f = __i.__ptr_;
1446 __base::__unlink_nodes(__f, __f);
1447 __link_nodes(__p.__ptr_, __f, __f);
1453 template <class _Tp, class _Alloc>
1454 void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l) {
1456 __base_pointer __first = __f.__ptr_;
1458 __base_pointer __last = __l.__ptr_;
1459 if (this != std::addressof(__c)) {
1460 size_type __s = std::distance(__f, __l) + 1;
1462 this->__size_ += __s;
1464 __base::__unlink_nodes(__first, __last);
1465 __link_nodes(__p.__ptr_, __first, __last);
1469 template <class _Tp, class _Alloc>
1470 typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove(const value_type& __x) {
1471 list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
1472 for (const_iterator __i = begin(), __e = end(); __i != __e;) {
1474 const_iterator __j = std::next(__i);
1475 for (; __j != __e && *__j == __x; ++__j)
1477 __deleted_nodes.splice(__deleted_nodes.end(), *this, __i, __j);
1485 return (__remove_return_type)__deleted_nodes.size();
1488 template <class _Tp, class _Alloc>
1489 template <class _Pred>
1490 typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove_if(_Pred __pred) {
1491 list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
1492 for (iterator __i = begin(), __e = end(); __i != __e;) {
1494 iterator __j = std::next(__i);
1495 for (; __j != __e && __pred(*__j); ++__j)
1497 __deleted_nodes.splice(__deleted_nodes.end(), *this, __i, __j);
1505 return (__remove_return_type)__deleted_nodes.size();
1508 template <class _Tp, class _Alloc>
1509 template <class _BinaryPred>
1510 typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::unique(_BinaryPred __binary_pred) {
1511 list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
1512 for (iterator __i = begin(), __e = end(); __i != __e;) {
1513 iterator __j = std::next(__i);
1514 for (; __j != __e && __binary_pred(*__i, *__j); ++__j)
1517 __deleted_nodes.splice(__deleted_nodes.end(), *this, __i, __j);
1522 return (__remove_return_type)__deleted_nodes.size();
1525 template <class _Tp, class _Alloc>
1526 inline void list<_Tp, _Alloc>::merge(list& __c) {
1527 merge(__c, __less<>());
1530 template <class _Tp, class _Alloc>
1531 template <class _Comp>
1532 void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) {
1533 if (this != std::addressof(__c)) {
1534 iterator __f1 = begin();
1535 iterator __e1 = end();
1536 iterator __f2 = __c.begin();
1537 iterator __e2 = __c.end();
1538 while (__f1 != __e1 && __f2 != __e2) {
1539 if (__comp(*__f2, *__f1)) {
1541 iterator __m2 = std::next(__f2);
1542 for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2, (void)++__ds)
1544 this->__size_ += __ds;
1545 __c.__size_ -= __ds;
1546 __base_pointer __f = __f2.__ptr_;
1547 __base_pointer __l = __m2.__ptr_->__prev_;
1549 __base::__unlink_nodes(__f, __l);
1550 __m2 = std::next(__f1);
1551 __link_nodes(__f1.__ptr_, __f, __l);
1560 template <class _Tp, class _Alloc>
1561 inline void list<_Tp, _Alloc>::sort() {
1565 template <class _Tp, class _Alloc>
1566 template <class _Comp>
1567 inline void list<_Tp, _Alloc>::sort(_Comp __comp) {
1568 __sort(begin(), end(), this->__size_, __comp);
1571 template <class _Tp, class _Alloc>
1572 template <class _Comp>
1573 typename list<_Tp, _Alloc>::iterator
1574 list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp) {
1580 if (__comp(*--__e2, *__f1)) {
1581 __base_pointer __f = __e2.__ptr_;
1582 __base::__unlink_nodes(__f, __f);
1583 __link_nodes(__f1.__ptr_, __f, __f);
1588 size_type __n2 = __n / 2;
1589 iterator __e1 = std::next(__f1, __n2);
1590 iterator __r = __f1 = __sort(__f1, __e1, __n2, __comp);
1591 iterator __f2 = __e1 = __sort(__e1, __e2, __n - __n2, __comp);
1592 if (__comp(*__f2, *__f1)) {
1593 iterator __m2 = std::next(__f2);
1594 for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)
1596 __base_pointer __f = __f2.__ptr_;
1597 __base_pointer __l = __m2.__ptr_->__prev_;
1600 __base::__unlink_nodes(__f, __l);
1601 __m2 = std::next(__f1);
1602 __link_nodes(__f1.__ptr_, __f, __l);
1606 while (__f1 != __e1 && __f2 != __e2) {
1607 if (__comp(*__f2, *__f1)) {
1608 iterator __m2 = std::next(__f2);
1609 for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)
1611 __base_pointer __f = __f2.__ptr_;
1612 __base_pointer __l = __m2.__ptr_->__prev_;
1616 __base::__unlink_nodes(__f, __l);
1617 __m2 = std::next(__f1);
1618 __link_nodes(__f1.__ptr_, __f, __l);
1626 template <class _Tp, class _Alloc>
1627 void list<_Tp, _Alloc>::reverse() _NOEXCEPT {
1628 if (this->__size_ > 1) {
1629 iterator __e = end();
1630 for (iterator __i = begin(); __i.__ptr_ != __e.__ptr_;) {
1631 std::swap(__i.__ptr_->__prev_, __i.__ptr_->__next_);
1632 __i.__ptr_ = __i.__ptr_->__prev_;
1634 std::swap(__e.__ptr_->__prev_, __e.__ptr_->__next_);
1638 template <class _Tp, class _Alloc>
1639 bool list<_Tp, _Alloc>::__invariants() const {
1640 return size() == std::distance(begin(), end());
1643 template <class _Tp, class _Alloc>
1644 inline _LIBCPP_HIDE_FROM_ABI bool operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
1645 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
1648 #if _LIBCPP_STD_VER <= 17
1650 template <class _Tp, class _Alloc>
1651 inline _LIBCPP_HIDE_FROM_ABI bool operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
1652 return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
1655 template <class _Tp, class _Alloc>
1656 inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
1657 return !(__x == __y);
1660 template <class _Tp, class _Alloc>
1661 inline _LIBCPP_HIDE_FROM_ABI bool operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
1665 template <class _Tp, class _Alloc>
1666 inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
1667 return !(__x < __y);
1670 template <class _Tp, class _Alloc>
1671 inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
1672 return !(__y < __x);
1675 #else // _LIBCPP_STD_VER <= 17
1677 template <class _Tp, class _Allocator>
1678 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
1679 operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) {
1680 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
1683 #endif // _LIBCPP_STD_VER <= 17
1685 template <class _Tp, class _Alloc>
1686 inline _LIBCPP_HIDE_FROM_ABI void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
1687 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
1691 #if _LIBCPP_STD_VER >= 20
1692 template <class _Tp, class _Allocator, class _Predicate>
1693 inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type
1694 erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred) {
1695 return __c.remove_if(__pred);
1698 template <class _Tp, class _Allocator, class _Up>
1699 inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type
1700 erase(list<_Tp, _Allocator>& __c, const _Up& __v) {
1701 return std::erase_if(__c, [&](auto& __elem) { return __elem == __v; });
1705 inline constexpr bool __format::__enable_insertable<std::list<char>> = true;
1706 # if _LIBCPP_HAS_WIDE_CHARACTERS
1708 inline constexpr bool __format::__enable_insertable<std::list<wchar_t>> = true;
1711 #endif // _LIBCPP_STD_VER >= 20
1713 template <class _Tp, class _Allocator>
1714 struct __container_traits<list<_Tp, _Allocator> > {
1715 // http://eel.is/c++draft/container.reqmts
1716 // Unless otherwise specified (see [associative.reqmts.except], [unord.req.except], [deque.modifiers],
1717 // [inplace.vector.modifiers], and [vector.modifiers]) all container types defined in this Clause meet the following
1718 // additional requirements:
1719 // - If an exception is thrown by an insert() or emplace() function while inserting a single element, that
1720 // function has no effects.
1721 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;
1724 _LIBCPP_END_NAMESPACE_STD
1726 #if _LIBCPP_STD_VER >= 17
1727 _LIBCPP_BEGIN_NAMESPACE_STD
1729 template <class _ValueT>
1730 using list _LIBCPP_AVAILABILITY_PMR = std::list<_ValueT, polymorphic_allocator<_ValueT>>;
1732 _LIBCPP_END_NAMESPACE_STD
1737 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1738 # include <algorithm>
1740 # include <concepts>
1743 # include <functional>
1745 # include <iterator>
1746 # include <stdexcept>
1747 # include <type_traits>
1748 # include <typeinfo>
1751 #endif // _LIBCPP_LIST