60 #if __cplusplus >= 201103L
64 namespace std _GLIBCXX_VISIBILITY(default)
68 _GLIBCXX_BEGIN_NAMESPACE_VERSION
90 _M_reverse() _GLIBCXX_USE_NOEXCEPT;
96 _M_unhook() _GLIBCXX_USE_NOEXCEPT;
99 _GLIBCXX_END_NAMESPACE_VERSION
102 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
105 template<
typename _Tp>
111 #if __cplusplus >= 201103L
112 template<
typename... _Args>
114 : __detail::_List_node_base(),
_M_data(std::
forward<_Args>(__args)...)
124 template<
typename _Tp>
130 typedef ptrdiff_t difference_type;
132 typedef _Tp value_type;
133 typedef _Tp* pointer;
134 typedef _Tp& reference;
144 _M_const_cast()
const
150 {
return static_cast<_Node*
>(_M_node)->_M_data; }
159 _M_node = _M_node->_M_next;
167 _M_node = _M_node->_M_next;
174 _M_node = _M_node->_M_prev;
182 _M_node = _M_node->_M_prev;
187 operator==(
const _Self& __x)
const
188 {
return _M_node == __x._M_node; }
191 operator!=(
const _Self& __x)
const
192 {
return _M_node != __x._M_node; }
203 template<
typename _Tp>
210 typedef ptrdiff_t difference_type;
212 typedef _Tp value_type;
213 typedef const _Tp* pointer;
214 typedef const _Tp& reference;
224 : _M_node(__x._M_node) { }
227 _M_const_cast()
const
228 {
return iterator(const_cast<__detail::_List_node_base*>(_M_node)); }
234 {
return static_cast<_Node*
>(_M_node)->_M_data; }
243 _M_node = _M_node->_M_next;
251 _M_node = _M_node->_M_next;
258 _M_node = _M_node->_M_prev;
266 _M_node = _M_node->_M_prev;
271 operator==(
const _Self& __x)
const
272 {
return _M_node == __x._M_node; }
275 operator!=(
const _Self& __x)
const
276 {
return _M_node != __x._M_node; }
282 template<
typename _Val>
286 {
return __x._M_node == __y._M_node; }
288 template<
typename _Val>
290 operator!=(
const _List_iterator<_Val>& __x,
291 const _List_const_iterator<_Val>& __y)
292 {
return __x._M_node != __y._M_node; }
296 template<
typename _Tp,
typename _Alloc>
313 typedef typename _Alloc::template rebind<_List_node<_Tp> >::other
316 typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
319 :
public _Node_alloc_type
324 : _Node_alloc_type(), _M_node()
327 _List_impl(
const _Node_alloc_type& __a)
328 : _Node_alloc_type(__a), _M_node()
331 #if __cplusplus >= 201103L
332 _List_impl(_Node_alloc_type&& __a)
333 : _Node_alloc_type(std::move(__a)), _M_node()
342 {
return _M_impl._Node_alloc_type::allocate(1); }
346 { _M_impl._Node_alloc_type::deallocate(__p, 1); }
349 typedef _Alloc allocator_type;
352 _M_get_Node_allocator() _GLIBCXX_NOEXCEPT
353 {
return *
static_cast<_Node_alloc_type*
>(&_M_impl); }
355 const _Node_alloc_type&
356 _M_get_Node_allocator()
const _GLIBCXX_NOEXCEPT
357 {
return *
static_cast<const _Node_alloc_type*
>(&_M_impl); }
360 _M_get_Tp_allocator()
const _GLIBCXX_NOEXCEPT
361 {
return _Tp_alloc_type(_M_get_Node_allocator()); }
364 get_allocator()
const _GLIBCXX_NOEXCEPT
365 {
return allocator_type(_M_get_Node_allocator()); }
375 #if __cplusplus >= 201103L
377 : _M_impl(std::move(__x._M_get_Node_allocator()))
380 __detail::_List_node_base::swap(_M_impl._M_node, __x._M_impl._M_node);
394 this->_M_impl._M_node._M_next = &this->_M_impl._M_node;
395 this->_M_impl._M_node._M_prev = &this->_M_impl._M_node;
445 template<
typename _Tp,
typename _Alloc = std::allocator<_Tp> >
449 typedef typename _Alloc::value_type _Alloc_value_type;
450 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
451 __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
454 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
455 typedef typename _Base::_Node_alloc_type _Node_alloc_type;
458 typedef _Tp value_type;
459 typedef typename _Tp_alloc_type::pointer pointer;
460 typedef typename _Tp_alloc_type::const_pointer const_pointer;
461 typedef typename _Tp_alloc_type::reference reference;
462 typedef typename _Tp_alloc_type::const_reference const_reference;
467 typedef size_t size_type;
468 typedef ptrdiff_t difference_type;
469 typedef _Alloc allocator_type;
476 using _Base::_M_impl;
477 using _Base::_M_put_node;
478 using _Base::_M_get_node;
479 using _Base::_M_get_Tp_allocator;
480 using _Base::_M_get_Node_allocator;
488 #if __cplusplus < 201103L
492 _Node* __p = this->_M_get_node();
495 _M_get_Tp_allocator().construct
501 __throw_exception_again;
506 template<
typename... _Args>
510 _Node* __p = this->_M_get_node();
513 _M_get_Node_allocator().construct(__p,
514 std::forward<_Args>(__args)...);
519 __throw_exception_again;
539 list(
const allocator_type& __a)
540 :
_Base(_Node_alloc_type(__a)) { }
542 #if __cplusplus >= 201103L
553 { _M_default_initialize(__n); }
563 list(size_type __n,
const value_type& __value,
564 const allocator_type& __a = allocator_type())
565 :
_Base(_Node_alloc_type(__a))
566 { _M_fill_initialize(__n, __value); }
577 list(size_type __n,
const value_type& __value = value_type(),
578 const allocator_type& __a = allocator_type())
579 : _Base(_Node_alloc_type(__a))
580 { _M_fill_initialize(__n, __value); }
591 :
_Base(__x._M_get_Node_allocator())
592 { _M_initialize_dispatch(__x.
begin(), __x.
end(), __false_type()); }
594 #if __cplusplus >= 201103L
603 :
_Base(std::move(__x)) { }
614 const allocator_type& __a = allocator_type())
615 :
_Base(_Node_alloc_type(__a))
616 { _M_initialize_dispatch(__l.begin(), __l.end(), __false_type()); }
629 #if __cplusplus >= 201103L
630 template<
typename _InputIterator,
631 typename = std::_RequireInputIter<_InputIterator>>
632 list(_InputIterator __first, _InputIterator __last,
633 const allocator_type& __a = allocator_type())
634 :
_Base(_Node_alloc_type(__a))
635 { _M_initialize_dispatch(__first, __last, __false_type()); }
637 template<
typename _InputIterator>
638 list(_InputIterator __first, _InputIterator __last,
639 const allocator_type& __a = allocator_type())
640 : _Base(_Node_alloc_type(__a))
643 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
644 _M_initialize_dispatch(__first, __last, _Integral());
666 #if __cplusplus >= 201103L
694 this->
assign(__l.begin(), __l.end());
710 assign(size_type __n,
const value_type& __val)
711 { _M_fill_assign(__n, __val); }
725 #if __cplusplus >= 201103L
726 template<
typename _InputIterator,
727 typename = std::_RequireInputIter<_InputIterator>>
729 assign(_InputIterator __first, _InputIterator __last)
730 { _M_assign_dispatch(__first, __last, __false_type()); }
732 template<
typename _InputIterator>
734 assign(_InputIterator __first, _InputIterator __last)
737 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
738 _M_assign_dispatch(__first, __last, _Integral());
742 #if __cplusplus >= 201103L
752 { this->
assign(__l.begin(), __l.end()); }
758 {
return _Base::get_allocator(); }
767 {
return iterator(this->_M_impl._M_node._M_next); }
785 {
return iterator(&this->_M_impl._M_node); }
793 end() const _GLIBCXX_NOEXCEPT
810 const_reverse_iterator
828 const_reverse_iterator
832 #if __cplusplus >= 201103L
856 const_reverse_iterator
865 const_reverse_iterator
877 {
return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; }
887 {
return _M_get_Node_allocator().max_size(); }
889 #if __cplusplus >= 201103L
900 resize(size_type __new_size);
913 resize(size_type __new_size,
const value_type& __x);
926 resize(size_type __new_size, value_type __x = value_type());
983 { this->_M_insert(
begin(), __x); }
985 #if __cplusplus >= 201103L
988 { this->_M_insert(
begin(), std::move(__x)); }
990 template<
typename... _Args>
992 emplace_front(_Args&&... __args)
993 { this->_M_insert(
begin(), std::forward<_Args>(__args)...); }
1010 { this->_M_erase(
begin()); }
1024 { this->_M_insert(
end(), __x); }
1026 #if __cplusplus >= 201103L
1029 { this->_M_insert(
end(), std::move(__x)); }
1031 template<
typename... _Args>
1033 emplace_back(_Args&&... __args)
1034 { this->_M_insert(
end(), std::forward<_Args>(__args)...); }
1050 { this->_M_erase(
iterator(this->_M_impl._M_node._M_prev)); }
1052 #if __cplusplus >= 201103L
1065 template<
typename... _Args>
1067 emplace(const_iterator __position, _Args&&... __args);
1081 insert(const_iterator __position,
const value_type& __x);
1098 #if __cplusplus >= 201103L
1112 {
return emplace(__position, std::move(__x)); }
1131 {
return this->
insert(__p, __l.begin(), __l.end()); }
1134 #if __cplusplus >= 201103L
1150 insert(const_iterator __position, size_type __n,
const value_type& __x);
1165 insert(
iterator __position, size_type __n,
const value_type& __x)
1168 splice(__position, __tmp);
1172 #if __cplusplus >= 201103L
1188 template<
typename _InputIterator,
1189 typename = std::_RequireInputIter<_InputIterator>>
1191 insert(const_iterator __position, _InputIterator __first,
1192 _InputIterator __last);
1207 template<
typename _InputIterator>
1209 insert(iterator __position, _InputIterator __first,
1210 _InputIterator __last)
1213 splice(__position, __tmp);
1233 #if __cplusplus >= 201103L
1234 erase(const_iterator __position);
1236 erase(iterator __position);
1258 #if __cplusplus >= 201103L
1264 while (__first != __last)
1265 __first =
erase(__first);
1266 return __last._M_const_cast();
1281 __detail::_List_node_base::swap(this->_M_impl._M_node,
1282 __x._M_impl._M_node);
1286 std::__alloc_swap<typename _Base::_Node_alloc_type>::
1287 _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator());
1316 #if __cplusplus >= 201103L
1324 _M_check_equal_allocators(__x);
1326 this->_M_transfer(__position._M_const_cast(),
1331 #if __cplusplus >= 201103L
1334 {
splice(__position, std::move(__x)); }
1337 #if __cplusplus >= 201103L
1364 iterator __j = __i._M_const_cast();
1366 if (__position == __i || __position == __j)
1370 _M_check_equal_allocators(__x);
1372 this->_M_transfer(__position._M_const_cast(),
1373 __i._M_const_cast(), __j);
1376 #if __cplusplus >= 201103L
1389 {
splice(__position, std::move(__x), __i); }
1392 #if __cplusplus >= 201103L
1427 if (__first != __last)
1430 _M_check_equal_allocators(__x);
1432 this->_M_transfer(__position._M_const_cast(),
1433 __first._M_const_cast(),
1434 __last._M_const_cast());
1438 #if __cplusplus >= 201103L
1455 {
splice(__position, std::move(__x), __first, __last); }
1470 remove(
const _Tp& __value);
1483 template<
typename _Predicate>
1512 template<
typename _BinaryPredicate>
1514 unique(_BinaryPredicate);
1525 #if __cplusplus >= 201103L
1531 {
merge(std::move(__x)); }
1550 #if __cplusplus >= 201103L
1551 template<
typename _StrictWeakOrdering>
1553 merge(
list&& __x, _StrictWeakOrdering __comp);
1555 template<
typename _StrictWeakOrdering>
1557 merge(
list& __x, _StrictWeakOrdering __comp)
1558 {
merge(std::move(__x), __comp); }
1560 template<
typename _StrictWeakOrdering>
1562 merge(
list& __x, _StrictWeakOrdering __comp);
1572 { this->_M_impl._M_node._M_reverse(); }
1589 template<
typename _StrictWeakOrdering>
1591 sort(_StrictWeakOrdering);
1600 template<
typename _Integer>
1602 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1603 { _M_fill_initialize(static_cast<size_type>(__n), __x); }
1606 template<
typename _InputIterator>
1608 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1611 for (; __first != __last; ++__first)
1612 #
if __cplusplus >= 201103L
1613 emplace_back(*__first);
1622 _M_fill_initialize(size_type __n,
const value_type& __x)
1628 #if __cplusplus >= 201103L
1631 _M_default_initialize(size_type __n)
1639 _M_default_append(size_type __n);
1648 template<
typename _Integer>
1650 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1651 { _M_fill_assign(__n, __val); }
1654 template<
typename _InputIterator>
1656 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1662 _M_fill_assign(size_type __n,
const value_type& __val);
1667 _M_transfer(iterator __position, iterator __first, iterator __last)
1668 { __position._M_node->_M_transfer(__first._M_node, __last._M_node); }
1671 #if __cplusplus < 201103L
1673 _M_insert(iterator __position,
const value_type& __x)
1676 __tmp->_M_hook(__position._M_node);
1679 template<
typename... _Args>
1681 _M_insert(iterator __position, _Args&&... __args)
1684 __tmp->_M_hook(__position._M_node);
1690 _M_erase(iterator __position)
1692 __position._M_node->_M_unhook();
1693 _Node* __n =
static_cast<_Node*
>(__position._M_node);
1694 #if __cplusplus >= 201103L
1695 _M_get_Node_allocator().destroy(__n);
1704 _M_check_equal_allocators(
list& __x)
1706 if (std::__alloc_neq<typename _Base::_Node_alloc_type>::
1707 _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator()))
1708 __throw_runtime_error(__N(
"list::_M_check_equal_allocators"));
1722 template<
typename _Tp,
typename _Alloc>
1727 const_iterator __end1 = __x.
end();
1728 const_iterator __end2 = __y.
end();
1730 const_iterator __i1 = __x.
begin();
1731 const_iterator __i2 = __y.
begin();
1732 while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2)
1737 return __i1 == __end1 && __i2 == __end2;
1751 template<
typename _Tp,
typename _Alloc>
1755 __y.begin(), __y.end()); }
1758 template<
typename _Tp,
typename _Alloc>
1761 {
return !(__x == __y); }
1764 template<
typename _Tp,
typename _Alloc>
1767 {
return __y < __x; }
1770 template<
typename _Tp,
typename _Alloc>
1773 {
return !(__y < __x); }
1776 template<
typename _Tp,
typename _Alloc>
1779 {
return !(__x < __y); }
1782 template<
typename _Tp,
typename _Alloc>
1787 _GLIBCXX_END_NAMESPACE_CONTAINER