60 #if __cplusplus >= 201103L
68 _GLIBCXX_BEGIN_NAMESPACE_VERSION
77 struct _List_node_base
79 _List_node_base* _M_next;
80 _List_node_base* _M_prev;
83 swap(_List_node_base& __x, _List_node_base& __y) _GLIBCXX_USE_NOEXCEPT;
86 _M_transfer(_List_node_base*
const __first,
87 _List_node_base*
const __last) _GLIBCXX_USE_NOEXCEPT;
90 _M_reverse() _GLIBCXX_USE_NOEXCEPT;
93 _M_hook(_List_node_base*
const __position) _GLIBCXX_USE_NOEXCEPT;
96 _M_unhook() _GLIBCXX_USE_NOEXCEPT;
99 _GLIBCXX_END_NAMESPACE_VERSION
102 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
105 template<
typename _Tp>
106 struct _List_node :
public __detail::_List_node_base
111 #if __cplusplus >= 201103L
112 template<
typename... _Args>
113 _List_node(_Args&&... __args)
114 : __detail::_List_node_base(), _M_data(std::forward<_Args>(__args)...)
124 template<
typename _Tp>
125 struct _List_iterator
127 typedef _List_iterator<_Tp> _Self;
128 typedef _List_node<_Tp> _Node;
131 typedef std::bidirectional_iterator_tag iterator_category;
132 typedef _Tp value_type;
133 typedef _Tp* pointer;
134 typedef _Tp& reference;
140 _List_iterator(__detail::_List_node_base* __x)
146 {
return static_cast<_Node*
>(_M_node)->_M_data; }
150 {
return std::__addressof(static_cast<_Node*>(_M_node)->_M_data); }
155 _M_node = _M_node->_M_next;
163 _M_node = _M_node->_M_next;
170 _M_node = _M_node->_M_prev;
178 _M_node = _M_node->_M_prev;
184 {
return _M_node == __x._M_node; }
188 {
return _M_node != __x._M_node; }
191 __detail::_List_node_base* _M_node;
199 template<
typename _Tp>
200 struct _List_const_iterator
202 typedef _List_const_iterator<_Tp> _Self;
203 typedef const _List_node<_Tp> _Node;
204 typedef _List_iterator<_Tp> iterator;
207 typedef std::bidirectional_iterator_tag iterator_category;
208 typedef _Tp value_type;
209 typedef const _Tp* pointer;
210 typedef const _Tp& reference;
212 _List_const_iterator()
216 _List_const_iterator(
const __detail::_List_node_base* __x)
219 _List_const_iterator(
const iterator& __x)
220 : _M_node(__x._M_node) { }
226 {
return static_cast<_Node*
>(_M_node)->_M_data; }
230 {
return std::__addressof(static_cast<_Node*>(_M_node)->_M_data); }
235 _M_node = _M_node->_M_next;
243 _M_node = _M_node->_M_next;
250 _M_node = _M_node->_M_prev;
258 _M_node = _M_node->_M_prev;
264 {
return _M_node == __x._M_node; }
268 {
return _M_node != __x._M_node; }
271 const __detail::_List_node_base* _M_node;
274 template<
typename _Val>
277 const _List_const_iterator<_Val>& __y)
278 {
return __x._M_node == __y._M_node; }
280 template<
typename _Val>
283 const _List_const_iterator<_Val>& __y)
284 {
return __x._M_node != __y._M_node; }
288 template<
typename _Tp,
typename _Alloc>
305 typedef typename _Alloc::template rebind<_List_node<_Tp> >::other
308 typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
311 :
public _Node_alloc_type
313 __detail::_List_node_base _M_node;
316 : _Node_alloc_type(), _M_node()
319 _List_impl(
const _Node_alloc_type& __a)
320 : _Node_alloc_type(__a), _M_node()
323 #if __cplusplus >= 201103L
324 _List_impl(_Node_alloc_type&& __a)
325 : _Node_alloc_type(std::move(__a)), _M_node()
334 {
return _M_impl._Node_alloc_type::allocate(1); }
337 _M_put_node(_List_node<_Tp>* __p)
338 { _M_impl._Node_alloc_type::deallocate(__p, 1); }
341 typedef _Alloc allocator_type;
344 _M_get_Node_allocator() _GLIBCXX_NOEXCEPT
345 {
return *
static_cast<_Node_alloc_type*
>(&_M_impl); }
347 const _Node_alloc_type&
348 _M_get_Node_allocator()
const _GLIBCXX_NOEXCEPT
349 {
return *
static_cast<const _Node_alloc_type*
>(&_M_impl); }
352 _M_get_Tp_allocator()
const _GLIBCXX_NOEXCEPT
353 {
return _Tp_alloc_type(_M_get_Node_allocator()); }
356 get_allocator()
const _GLIBCXX_NOEXCEPT
357 {
return allocator_type(_M_get_Node_allocator()); }
363 _List_base(
const _Node_alloc_type& __a)
367 #if __cplusplus >= 201103L
368 _List_base(_List_base&& __x)
369 : _M_impl(std::move(__x._M_get_Node_allocator()))
377 ~_List_base() _GLIBCXX_NOEXCEPT
386 this->_M_impl._M_node._M_next = &this->_M_impl._M_node;
387 this->_M_impl._M_node._M_prev = &this->_M_impl._M_node;
437 template<
typename _Tp,
typename _Alloc = std::allocator<_Tp> >
438 class list :
protected _List_base<_Tp, _Alloc>
441 typedef typename _Alloc::value_type _Alloc_value_type;
445 typedef _List_base<_Tp, _Alloc> _Base;
446 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
447 typedef typename _Base::_Node_alloc_type _Node_alloc_type;
450 typedef _Tp value_type;
451 typedef typename _Tp_alloc_type::pointer pointer;
452 typedef typename _Tp_alloc_type::const_pointer const_pointer;
453 typedef typename _Tp_alloc_type::reference reference;
454 typedef typename _Tp_alloc_type::const_reference const_reference;
455 typedef _List_iterator<_Tp> iterator;
456 typedef _List_const_iterator<_Tp> const_iterator;
457 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
458 typedef std::reverse_iterator<iterator> reverse_iterator;
459 typedef size_t size_type;
461 typedef _Alloc allocator_type;
466 typedef _List_node<_Tp> _Node;
468 using _Base::_M_impl;
469 using _Base::_M_put_node;
470 using _Base::_M_get_node;
471 using _Base::_M_get_Tp_allocator;
472 using _Base::_M_get_Node_allocator;
480 #if __cplusplus < 201103L
482 _M_create_node(
const value_type& __x)
484 _Node* __p = this->_M_get_node();
487 _M_get_Tp_allocator().construct
488 (std::__addressof(__p->_M_data), __x);
498 template<
typename... _Args>
500 _M_create_node(_Args&&... __args)
502 _Node* __p = this->_M_get_node();
505 _M_get_Node_allocator().construct(__p,
506 std::forward<_Args>(__args)...);
531 list(
const allocator_type& __a)
532 : _Base(_Node_alloc_type(__a)) { }
534 #if __cplusplus >= 201103L
545 { _M_default_initialize(__n); }
555 list(size_type __n,
const value_type& __value,
556 const allocator_type& __a = allocator_type())
557 : _Base(_Node_alloc_type(__a))
558 { _M_fill_initialize(__n, __value); }
569 list(size_type __n,
const value_type& __value = value_type(),
570 const allocator_type& __a = allocator_type())
571 : _Base(_Node_alloc_type(__a))
572 { _M_fill_initialize(__n, __value); }
582 list(
const list& __x)
583 : _Base(__x._M_get_Node_allocator())
584 { _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); }
586 #if __cplusplus >= 201103L
594 list(list&& __x) noexcept
595 : _Base(std::move(__x)) { }
605 list(initializer_list<value_type> __l,
606 const allocator_type& __a = allocator_type())
607 : _Base(_Node_alloc_type(__a))
608 { _M_initialize_dispatch(__l.begin(), __l.end(), __false_type()); }
621 #if __cplusplus >= 201103L
622 template<
typename _InputIterator,
623 typename = std::_RequireInputIter<_InputIterator>>
624 list(_InputIterator __first, _InputIterator __last,
625 const allocator_type& __a = allocator_type())
626 : _Base(_Node_alloc_type(__a))
627 { _M_initialize_dispatch(__first, __last, __false_type()); }
629 template<
typename _InputIterator>
630 list(_InputIterator __first, _InputIterator __last,
631 const allocator_type& __a = allocator_type())
632 : _Base(_Node_alloc_type(__a))
635 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
636 _M_initialize_dispatch(__first, __last, _Integral());
656 operator=(
const list& __x);
658 #if __cplusplus >= 201103L
667 operator=(list&& __x)
684 operator=(initializer_list<value_type> __l)
686 this->assign(__l.begin(), __l.end());
702 assign(size_type __n,
const value_type& __val)
703 { _M_fill_assign(__n, __val); }
717 #if __cplusplus >= 201103L
718 template<
typename _InputIterator,
719 typename = std::_RequireInputIter<_InputIterator>>
721 assign(_InputIterator __first, _InputIterator __last)
722 { _M_assign_dispatch(__first, __last, __false_type()); }
724 template<
typename _InputIterator>
726 assign(_InputIterator __first, _InputIterator __last)
729 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
730 _M_assign_dispatch(__first, __last, _Integral());
734 #if __cplusplus >= 201103L
743 assign(initializer_list<value_type> __l)
744 { this->assign(__l.begin(), __l.end()); }
749 get_allocator()
const _GLIBCXX_NOEXCEPT
750 {
return _Base::get_allocator(); }
758 begin() _GLIBCXX_NOEXCEPT
759 {
return iterator(this->_M_impl._M_node._M_next); }
767 begin()
const _GLIBCXX_NOEXCEPT
768 {
return const_iterator(this->_M_impl._M_node._M_next); }
776 end() _GLIBCXX_NOEXCEPT
777 {
return iterator(&this->_M_impl._M_node); }
785 end()
const _GLIBCXX_NOEXCEPT
786 {
return const_iterator(&this->_M_impl._M_node); }
794 rbegin() _GLIBCXX_NOEXCEPT
795 {
return reverse_iterator(end()); }
802 const_reverse_iterator
803 rbegin()
const _GLIBCXX_NOEXCEPT
804 {
return const_reverse_iterator(end()); }
812 rend() _GLIBCXX_NOEXCEPT
813 {
return reverse_iterator(begin()); }
820 const_reverse_iterator
821 rend()
const _GLIBCXX_NOEXCEPT
822 {
return const_reverse_iterator(begin()); }
824 #if __cplusplus >= 201103L
831 cbegin()
const noexcept
832 {
return const_iterator(this->_M_impl._M_node._M_next); }
840 cend()
const noexcept
841 {
return const_iterator(&this->_M_impl._M_node); }
848 const_reverse_iterator
849 crbegin()
const noexcept
850 {
return const_reverse_iterator(end()); }
857 const_reverse_iterator
858 crend()
const noexcept
859 {
return const_reverse_iterator(begin()); }
868 empty()
const _GLIBCXX_NOEXCEPT
869 {
return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; }
873 size()
const _GLIBCXX_NOEXCEPT
874 {
return std::distance(begin(), end()); }
878 max_size()
const _GLIBCXX_NOEXCEPT
879 {
return _M_get_Node_allocator().max_size(); }
881 #if __cplusplus >= 201103L
892 resize(size_type __new_size);
905 resize(size_type __new_size,
const value_type& __x);
918 resize(size_type __new_size, value_type __x = value_type());
945 iterator __tmp = end();
957 const_iterator __tmp = end();
974 push_front(
const value_type& __x)
975 { this->_M_insert(begin(), __x); }
977 #if __cplusplus >= 201103L
979 push_front(value_type&& __x)
980 { this->_M_insert(begin(), std::move(__x)); }
982 template<
typename... _Args>
984 emplace_front(_Args&&... __args)
985 { this->_M_insert(begin(), std::forward<_Args>(__args)...); }
1002 { this->_M_erase(begin()); }
1015 push_back(
const value_type& __x)
1016 { this->_M_insert(end(), __x); }
1018 #if __cplusplus >= 201103L
1020 push_back(value_type&& __x)
1021 { this->_M_insert(end(), std::move(__x)); }
1023 template<
typename... _Args>
1025 emplace_back(_Args&&... __args)
1026 { this->_M_insert(end(), std::forward<_Args>(__args)...); }
1042 { this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); }
1044 #if __cplusplus >= 201103L
1057 template<
typename... _Args>
1059 emplace(iterator __position, _Args&&... __args);
1074 insert(iterator __position,
const value_type& __x);
1076 #if __cplusplus >= 201103L
1089 insert(iterator __position, value_type&& __x)
1090 {
return emplace(__position, std::move(__x)); }
1106 insert(iterator __p, initializer_list<value_type> __l)
1107 { this->insert(__p, __l.begin(), __l.end()); }
1123 insert(iterator __position, size_type __n,
const value_type& __x)
1125 list __tmp(__n, __x, get_allocator());
1126 splice(__position, __tmp);
1142 #if __cplusplus >= 201103L
1143 template<
typename _InputIterator,
1144 typename = std::_RequireInputIter<_InputIterator>>
1146 template<
typename _InputIterator>
1149 insert(iterator __position, _InputIterator __first,
1150 _InputIterator __last)
1152 list __tmp(__first, __last, get_allocator());
1153 splice(__position, __tmp);
1172 erase(iterator __position);
1193 erase(iterator __first, iterator __last)
1195 while (__first != __last)
1196 __first = erase(__first);
1213 __x._M_impl._M_node);
1217 std::__alloc_swap<typename _Base::_Node_alloc_type>::
1218 _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator());
1228 clear() _GLIBCXX_NOEXCEPT
1247 #if __cplusplus >= 201103L
1248 splice(iterator __position, list&& __x)
1250 splice(iterator __position, list& __x)
1255 _M_check_equal_allocators(__x);
1257 this->_M_transfer(__position, __x.begin(), __x.end());
1261 #if __cplusplus >= 201103L
1263 splice(iterator __position, list& __x)
1264 { splice(__position, std::move(__x)); }
1277 #if __cplusplus >= 201103L
1278 splice(iterator __position, list&& __x, iterator __i)
1280 splice(iterator __position, list& __x, iterator __i)
1285 if (__position == __i || __position == __j)
1289 _M_check_equal_allocators(__x);
1291 this->_M_transfer(__position, __i, __j);
1294 #if __cplusplus >= 201103L
1296 splice(iterator __position, list& __x, iterator __i)
1297 { splice(__position, std::move(__x), __i); }
1313 #if __cplusplus >= 201103L
1314 splice(iterator __position, list&& __x, iterator __first,
1317 splice(iterator __position, list& __x, iterator __first,
1321 if (__first != __last)
1324 _M_check_equal_allocators(__x);
1326 this->_M_transfer(__position, __first, __last);
1330 #if __cplusplus >= 201103L
1332 splice(iterator __position, list& __x, iterator __first, iterator __last)
1333 { splice(__position, std::move(__x), __first, __last); }
1348 remove(
const _Tp& __value);
1361 template<
typename _Predicate>
1363 remove_if(_Predicate);
1390 template<
typename _BinaryPredicate>
1392 unique(_BinaryPredicate);
1403 #if __cplusplus >= 201103L
1409 { merge(std::move(__x)); }
1428 #if __cplusplus >= 201103L
1429 template<
typename _StrictWeakOrdering>
1431 merge(list&& __x, _StrictWeakOrdering __comp);
1433 template<
typename _StrictWeakOrdering>
1435 merge(list& __x, _StrictWeakOrdering __comp)
1436 { merge(std::move(__x), __comp); }
1438 template<
typename _StrictWeakOrdering>
1440 merge(list& __x, _StrictWeakOrdering __comp);
1449 reverse() _GLIBCXX_NOEXCEPT
1450 { this->_M_impl._M_node._M_reverse(); }
1467 template<
typename _StrictWeakOrdering>
1469 sort(_StrictWeakOrdering);
1478 template<
typename _Integer>
1480 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1481 { _M_fill_initialize(static_cast<size_type>(__n), __x); }
1484 template<
typename _InputIterator>
1486 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1489 for (; __first != __last; ++__first)
1490 #
if __cplusplus >= 201103L
1491 emplace_back(*__first);
1493 push_back(*__first);
1500 _M_fill_initialize(size_type __n,
const value_type& __x)
1506 #if __cplusplus >= 201103L
1509 _M_default_initialize(size_type __n)
1517 _M_default_append(size_type __n);
1526 template<
typename _Integer>
1528 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1529 { _M_fill_assign(__n, __val); }
1532 template<
typename _InputIterator>
1534 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1540 _M_fill_assign(size_type __n,
const value_type& __val);
1545 _M_transfer(iterator __position, iterator __first, iterator __last)
1546 { __position._M_node->_M_transfer(__first._M_node, __last._M_node); }
1549 #if __cplusplus < 201103L
1551 _M_insert(iterator __position,
const value_type& __x)
1553 _Node* __tmp = _M_create_node(__x);
1554 __tmp->_M_hook(__position._M_node);
1557 template<
typename... _Args>
1559 _M_insert(iterator __position, _Args&&... __args)
1561 _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
1562 __tmp->_M_hook(__position._M_node);
1568 _M_erase(iterator __position)
1570 __position._M_node->_M_unhook();
1571 _Node* __n =
static_cast<_Node*
>(__position._M_node);
1572 #if __cplusplus >= 201103L
1573 _M_get_Node_allocator().destroy(__n);
1575 _M_get_Tp_allocator().destroy(std::__addressof(__n->_M_data));
1582 _M_check_equal_allocators(list& __x)
1584 if (std::__alloc_neq<typename _Base::_Node_alloc_type>::
1585 _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator()))
1586 __throw_runtime_error(__N(
"list::_M_check_equal_allocators"));
1600 template<
typename _Tp,
typename _Alloc>
1602 operator==(
const list<_Tp, _Alloc>& __x,
const list<_Tp, _Alloc>& __y)
1604 typedef typename list<_Tp, _Alloc>::const_iterator const_iterator;
1605 const_iterator __end1 = __x.end();
1606 const_iterator __end2 = __y.end();
1608 const_iterator __i1 = __x.begin();
1609 const_iterator __i2 = __y.begin();
1610 while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2)
1615 return __i1 == __end1 && __i2 == __end2;
1629 template<
typename _Tp,
typename _Alloc>
1631 operator<(const list<_Tp, _Alloc>& __x,
const list<_Tp, _Alloc>& __y)
1632 {
return std::lexicographical_compare(__x.begin(), __x.end(),
1633 __y.begin(), __y.end()); }
1636 template<
typename _Tp,
typename _Alloc>
1638 operator!=(
const list<_Tp, _Alloc>& __x,
const list<_Tp, _Alloc>& __y)
1639 {
return !(__x == __y); }
1642 template<
typename _Tp,
typename _Alloc>
1644 operator>(
const list<_Tp, _Alloc>& __x,
const list<_Tp, _Alloc>& __y)
1645 {
return __y < __x; }
1648 template<
typename _Tp,
typename _Alloc>
1650 operator<=(const list<_Tp, _Alloc>& __x,
const list<_Tp, _Alloc>& __y)
1651 {
return !(__y < __x); }
1654 template<
typename _Tp,
typename _Alloc>
1656 operator>=(
const list<_Tp, _Alloc>& __x,
const list<_Tp, _Alloc>& __y)
1657 {
return !(__x < __y); }
1660 template<
typename _Tp,
typename _Alloc>
1662 swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
1665 _GLIBCXX_END_NAMESPACE_CONTAINER
bool operator>=(const _Safe_iterator< _IteratorL, _Sequence > &__lhs, const _Safe_iterator< _IteratorR, _Sequence > &__rhs)
Definition: safe_iterator.h:644
bool operator==(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
namespace std _GLIBCXX_VISIBILITY(default)
Definition: stl_list.h:64
#define __try
Definition: exception_defines.h:35
#define __throw_exception_again
Definition: exception_defines.h:37
#define __glibcxx_class_requires(_a, _b)
Definition: concept_check.h:48
bool operator>(const _Safe_iterator< _IteratorL, _Sequence > &__lhs, const _Safe_iterator< _IteratorR, _Sequence > &__rhs)
Definition: safe_iterator.h:612
#define __glibcxx_class_requires2(_a, _b, _c)
Definition: concept_check.h:49
bool operator!=(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
#define __catch(X)
Definition: exception_defines.h:36
__PTRDIFF_TYPE__ ptrdiff_t
Definition: stddef.h:147
void swap(exception_ptr &__lhs, exception_ptr &__rhs)
Definition: exception_ptr.h:160