59namespace std _GLIBCXX_VISIBILITY(default)
61_GLIBCXX_BEGIN_NAMESPACE_VERSION
62_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
64 template<
typename _Tp,
typename _Alloc>
71 while (__cur != &_M_impl._M_node)
73 _Node* __tmp =
static_cast<_Node*
>(__cur);
74 __cur = __tmp->_M_next;
75 _Tp* __val = __tmp->_M_valptr();
76#if __cplusplus >= 201103L
77 _Node_alloc_traits::destroy(_M_get_Node_allocator(), __val);
79 _Tp_alloc_type(_M_get_Node_allocator()).destroy(__val);
85#if __cplusplus >= 201103L
86 template<
typename _Tp,
typename _Alloc>
87 template<
typename... _Args>
88 typename list<_Tp, _Alloc>::iterator
90 emplace(const_iterator __position, _Args&&... __args)
93 __tmp->_M_hook(__position._M_const_cast()._M_node);
95 return iterator(__tmp);
99 template<
typename _Tp,
typename _Alloc>
100 typename list<_Tp, _Alloc>::iterator
102#if __cplusplus >= 201103L
103 insert(const_iterator __position,
const value_type& __x)
105 insert(iterator __position,
const value_type& __x)
109 __tmp->_M_hook(__position._M_const_cast()._M_node);
110 this->_M_inc_size(1);
111 return iterator(__tmp);
114#if __cplusplus >= 201103L
115 template<
typename _Tp,
typename _Alloc>
116 typename list<_Tp, _Alloc>::iterator
118 insert(const_iterator __position, size_type __n,
const value_type& __x)
123 iterator __it = __tmp.
begin();
124 splice(__position, __tmp);
127 return __position._M_const_cast();
130 template<
typename _Tp,
typename _Alloc>
131 template<
typename _InputIterator,
typename>
132 typename list<_Tp, _Alloc>::iterator
134 insert(const_iterator __position, _InputIterator __first,
135 _InputIterator __last)
140 iterator __it = __tmp.
begin();
141 splice(__position, __tmp);
144 return __position._M_const_cast();
148 template<
typename _Tp,
typename _Alloc>
149 typename list<_Tp, _Alloc>::iterator
151#if __cplusplus >= 201103L
152 erase(const_iterator __position)
noexcept
154 erase(iterator __position)
157 iterator __ret = iterator(__position._M_node->_M_next);
158 _M_erase(__position._M_const_cast());
173 template<
typename _Tp,
typename _Alloc>
174 typename list<_Tp, _Alloc>::const_iterator
179#if _GLIBCXX_USE_CXX11_ABI
181 if (__new_size < __len)
183 if (__new_size <= __len / 2)
191 ptrdiff_t __num_erase = __len - __new_size;
201 for (__i =
begin(); __i !=
end() && __len < __new_size; ++__i, ++__len)
208#if __cplusplus >= 201103L
209 template<
typename _Tp,
typename _Alloc>
217 for (; __i < __n; ++__i)
224 __throw_exception_again;
228 template<
typename _Tp,
typename _Alloc>
231 resize(size_type __new_size)
233 const_iterator __i = _M_resize_pos(__new_size);
235 _M_default_append(__new_size);
240 template<
typename _Tp,
typename _Alloc>
243 resize(size_type __new_size,
const value_type& __x)
245 const_iterator __i = _M_resize_pos(__new_size);
252 template<
typename _Tp,
typename _Alloc>
257 const_iterator __i = _M_resize_pos(__new_size);
259 insert(
end(), __new_size, __x);
261 erase(__i._M_const_cast(),
end());
265 template<
typename _Tp,
typename _Alloc>
272#if __cplusplus >= 201103L
273 if (_Node_alloc_traits::_S_propagate_on_copy_assign())
275 auto& __this_alloc = this->_M_get_Node_allocator();
276 auto& __that_alloc = __x._M_get_Node_allocator();
277 if (!_Node_alloc_traits::_S_always_equal()
278 && __this_alloc != __that_alloc)
283 std::__alloc_on_copy(__this_alloc, __that_alloc);
286 _M_assign_dispatch(__x.
begin(), __x.
end(), __false_type());
291 template<
typename _Tp,
typename _Alloc>
297 for (; __i !=
end() && __n > 0; ++__i, --__n)
300 insert(
end(), __n, __val);
305 template<
typename _Tp,
typename _Alloc>
306 template <
typename _InputIterator>
309 _M_assign_dispatch(_InputIterator __first2, _InputIterator __last2,
312 iterator __first1 =
begin();
313 iterator __last1 =
end();
314 for (; __first1 != __last1 && __first2 != __last2;
315 ++__first1, (void)++__first2)
316 *__first1 = *__first2;
317 if (__first2 == __last2)
318 erase(__first1, __last1);
320 insert(__last1, __first2, __last2);
323#if __cplusplus > 201703L
324# define _GLIBCXX20_ONLY(__expr) __expr
326# define _GLIBCXX20_ONLY(__expr)
329 template<
typename _Tp,
typename _Alloc>
330 typename list<_Tp, _Alloc>::__remove_return_type
332 remove(
const value_type& __value)
334#if !_GLIBCXX_USE_CXX11_ABI
335 size_type __removed __attribute__((__unused__)) = 0;
338 iterator __first =
begin();
339 iterator __last =
end();
340 while (__first != __last)
342 iterator __next = __first;
344 if (*__first == __value)
349 __to_destroy.
splice(__to_destroy.
begin(), *
this, __first);
350#if !_GLIBCXX_USE_CXX11_ABI
351 _GLIBCXX20_ONLY( __removed++ );
358#if !_GLIBCXX_USE_CXX11_ABI
359 return _GLIBCXX20_ONLY( __removed );
361 return _GLIBCXX20_ONLY( __to_destroy.
size() );
365 template<
typename _Tp,
typename _Alloc>
366 typename list<_Tp, _Alloc>::__remove_return_type
370 iterator __first =
begin();
371 iterator __last =
end();
372 if (__first == __last)
373 return _GLIBCXX20_ONLY( 0 );
374#if !_GLIBCXX_USE_CXX11_ABI
375 size_type __removed __attribute__((__unused__)) = 0;
378 iterator __next = __first;
379 while (++__next != __last)
381 if (*__first == *__next)
383 __to_destroy.
splice(__to_destroy.
begin(), *
this, __next);
384#if !_GLIBCXX_USE_CXX11_ABI
385 _GLIBCXX20_ONLY( __removed++ );
393#if !_GLIBCXX_USE_CXX11_ABI
394 return _GLIBCXX20_ONLY( __removed );
396 return _GLIBCXX20_ONLY( __to_destroy.
size() );
400 template<
typename _Tp,
typename _Alloc>
403#if __cplusplus >= 201103L
413 _M_check_equal_allocators(__x);
415 iterator __first1 =
begin();
416 iterator __last1 =
end();
417 iterator __first2 = __x.
begin();
418 iterator __last2 = __x.
end();
420 const _Finalize_merge __fin(*
this, __x, __first2);
422 while (__first1 != __last1 && __first2 != __last2)
423 if (*__first2 < *__first1)
425 iterator __next = __first2;
426 _M_transfer(__first1, __first2, ++__next);
431 if (__first2 != __last2)
433 _M_transfer(__last1, __first2, __last2);
439 template<
typename _Tp,
typename _Alloc>
440 template <
typename _StrictWeakOrdering>
443#if __cplusplus >= 201103L
444 merge(
list&& __x, _StrictWeakOrdering __comp)
446 merge(
list& __x, _StrictWeakOrdering __comp)
453 _M_check_equal_allocators(__x);
455 iterator __first1 =
begin();
456 iterator __last1 =
end();
457 iterator __first2 = __x.
begin();
458 iterator __last2 = __x.
end();
460 const _Finalize_merge __fin(*
this, __x, __first2);
462 while (__first1 != __last1 && __first2 != __last2)
463 if (__comp(*__first2, *__first1))
465 iterator __next = __first2;
466 _M_transfer(__first1, __first2, ++__next);
471 if (__first2 != __last2)
473 _M_transfer(__last1, __first2, __last2);
479 template<
typename _Tp,
typename _Alloc>
485 if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
486 && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
490 list * __fill = __tmp;
498 for(__counter = __tmp;
499 __counter != __fill && !__counter->
empty();
502 __counter->
merge(__carry);
503 __carry.
swap(*__counter);
505 __carry.
swap(*__counter);
506 if (__counter == __fill)
511 for (__counter = __tmp + 1; __counter != __fill; ++__counter)
512 __counter->
merge(*(__counter - 1));
513 swap( *(__fill - 1) );
518 for (
int __i = 0; __i <
sizeof(__tmp)/
sizeof(__tmp[0]); ++__i)
520 __throw_exception_again;
525 template<
typename _Tp,
typename _Alloc>
526 template <
typename _Predicate>
527 typename list<_Tp, _Alloc>::__remove_return_type
531#if !_GLIBCXX_USE_CXX11_ABI
532 size_type __removed __attribute__((__unused__)) = 0;
535 iterator __first =
begin();
536 iterator __last =
end();
537 while (__first != __last)
539 iterator __next = __first;
541 if (__pred(*__first))
543 __to_destroy.
splice(__to_destroy.
begin(), *
this, __first);
544#if !_GLIBCXX_USE_CXX11_ABI
545 _GLIBCXX20_ONLY( __removed++ );
551#if !_GLIBCXX_USE_CXX11_ABI
552 return _GLIBCXX20_ONLY( __removed );
554 return _GLIBCXX20_ONLY( __to_destroy.
size() );
558 template<
typename _Tp,
typename _Alloc>
559 template <
typename _BinaryPredicate>
560 typename list<_Tp, _Alloc>::__remove_return_type
562 unique(_BinaryPredicate __binary_pred)
564 iterator __first =
begin();
565 iterator __last =
end();
566 if (__first == __last)
567 return _GLIBCXX20_ONLY(0);
568#if !_GLIBCXX_USE_CXX11_ABI
569 size_type __removed __attribute__((__unused__)) = 0;
572 iterator __next = __first;
573 while (++__next != __last)
575 if (__binary_pred(*__first, *__next))
577 __to_destroy.
splice(__to_destroy.
begin(), *
this, __next);
578#if !_GLIBCXX_USE_CXX11_ABI
579 _GLIBCXX20_ONLY( __removed++ );
587#if !_GLIBCXX_USE_CXX11_ABI
588 return _GLIBCXX20_ONLY( __removed );
590 return _GLIBCXX20_ONLY( __to_destroy.
size() );
594#undef _GLIBCXX20_ONLY
596 template<
typename _Tp,
typename _Alloc>
597 template <
typename _StrictWeakOrdering>
600 sort(_StrictWeakOrdering __comp)
603 if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
604 && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
608 list * __fill = __tmp;
616 for(__counter = __tmp;
617 __counter != __fill && !__counter->
empty();
620 __counter->
merge(__carry, __comp);
621 __carry.
swap(*__counter);
623 __carry.
swap(*__counter);
624 if (__counter == __fill)
629 for (__counter = __tmp + 1; __counter != __fill; ++__counter)
630 __counter->
merge(*(__counter - 1), __comp);
636 for (
int __i = 0; __i <
sizeof(__tmp)/
sizeof(__tmp[0]); ++__i)
638 __throw_exception_again;
643_GLIBCXX_END_NAMESPACE_CONTAINER
644_GLIBCXX_END_NAMESPACE_VERSION
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
_Tp * end(valarray< _Tp > &__va) noexcept
Return an iterator pointing to one past the last element of the valarray.
_Tp * begin(valarray< _Tp > &__va) noexcept
Return an iterator pointing to the first element of the valarray.
ISO C++ entities toplevel namespace is std.
constexpr auto empty(const _Container &__cont) noexcept(noexcept(__cont.empty())) -> decltype(__cont.empty())
Return whether a container is empty.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
constexpr void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
Common part of a node in the list.
An actual node in the list.
See bits/stl_deque.h's _Deque_base for an explanation.
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
void resize(size_type __new_size)
Resizes the list to the specified number of elements.
iterator insert(const_iterator __position, const value_type &__x)
Inserts given value into list before specified iterator.
void sort()
Sort the elements.
iterator begin() noexcept
iterator emplace(const_iterator __position, _Args &&... __args)
Constructs object in list before specified iterator.
_Node * _M_create_node(_Args &&... __args)
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
list & operator=(const list &__x)
List assignment operator.
__remove_return_type unique()
Remove consecutive duplicate elements.
size_type size() const noexcept
void merge(list &&__x)
Merge sorted lists.
__remove_return_type remove(const _Tp &__value)
Remove all elements equal to value.
list()=default
Creates a list with no elements.
__remove_return_type remove_if(_Predicate)
Remove all elements satisfying a predicate.
void splice(const_iterator __position, list &&__x) noexcept
Insert contents of another list.
iterator erase(const_iterator __position) noexcept
Remove element at given position.
bool empty() const noexcept
void swap(list &__x) noexcept
Swaps data with another list.