57 #define _STL_DEQUE_H 1 
   62 #if __cplusplus >= 201103L 
   66 namespace std _GLIBCXX_VISIBILITY(default)
 
   68 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 
   84 #ifndef _GLIBCXX_DEQUE_BUF_SIZE 
   85 #define _GLIBCXX_DEQUE_BUF_SIZE 512 
   89   __deque_buf_size(
size_t __size)
 
  105   template<
typename _Tp, 
typename _Ref, 
typename _Ptr>
 
  111       static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT
 
  112       { 
return __deque_buf_size(
sizeof(_Tp)); }
 
  115       typedef _Tp                             value_type;
 
  116       typedef _Ptr                            pointer;
 
  117       typedef _Ref                            reference;
 
  118       typedef size_t                          size_type;
 
  119       typedef ptrdiff_t                       difference_type;
 
  120       typedef _Tp**                           _Map_pointer;
 
  126       _Map_pointer _M_node;
 
  129       : _M_cur(__x), _M_first(*__y),
 
  130         _M_last(*__y + _S_buffer_size()), _M_node(__y) { }
 
  133       : _M_cur(0), _M_first(0), _M_last(0), _M_node(0) { }
 
  136       : _M_cur(__x._M_cur), _M_first(__x._M_first),
 
  137         _M_last(__x._M_last), _M_node(__x._M_node) { }
 
  140       _M_const_cast() 
const _GLIBCXX_NOEXCEPT
 
  141       { 
return iterator(_M_cur, _M_node); }
 
  144       operator*() 
const _GLIBCXX_NOEXCEPT
 
  148       operator->() 
const _GLIBCXX_NOEXCEPT
 
  152       operator++() _GLIBCXX_NOEXCEPT
 
  155     if (_M_cur == _M_last)
 
  164       operator++(
int) _GLIBCXX_NOEXCEPT
 
  172       operator--() _GLIBCXX_NOEXCEPT
 
  174     if (_M_cur == _M_first)
 
  184       operator--(
int) _GLIBCXX_NOEXCEPT
 
  192       operator+=(difference_type __n) _GLIBCXX_NOEXCEPT
 
  194     const difference_type __offset = __n + (_M_cur - _M_first);
 
  195     if (__offset >= 0 && __offset < difference_type(_S_buffer_size()))
 
  199         const difference_type __node_offset =
 
  200           __offset > 0 ? __offset / difference_type(_S_buffer_size())
 
  201                        : -difference_type((-__offset - 1)
 
  202                           / _S_buffer_size()) - 1;
 
  204         _M_cur = _M_first + (__offset - __node_offset
 
  205                  * difference_type(_S_buffer_size()));
 
  211       operator+(difference_type __n) 
const _GLIBCXX_NOEXCEPT
 
  218       operator-=(difference_type __n) _GLIBCXX_NOEXCEPT
 
  219       { 
return *
this += -__n; }
 
  222       operator-(difference_type __n) 
const _GLIBCXX_NOEXCEPT
 
  229       operator[](difference_type __n) 
const _GLIBCXX_NOEXCEPT
 
  230       { 
return *(*
this + __n); }
 
  240     _M_node = __new_node;
 
  241     _M_first = *__new_node;
 
  242     _M_last = _M_first + difference_type(_S_buffer_size());
 
  249   template<
typename _Tp, 
typename _Ref, 
typename _Ptr>
 
  251     operator==(
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
 
  252            const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT
 
  253     { 
return __x._M_cur == __y._M_cur; }
 
  255   template<
typename _Tp, 
typename _RefL, 
typename _PtrL,
 
  256        typename _RefR, 
typename _PtrR>
 
  258     operator==(
const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
 
  259            const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
 
  260     { 
return __x._M_cur == __y._M_cur; }
 
  262   template<
typename _Tp, 
typename _Ref, 
typename _Ptr>
 
  264     operator!=(
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
 
  265            const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT
 
  266     { 
return !(__x == __y); }
 
  268   template<
typename _Tp, 
typename _RefL, 
typename _PtrL,
 
  269        typename _RefR, 
typename _PtrR>
 
  271     operator!=(
const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
 
  272            const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
 
  273     { 
return !(__x == __y); }
 
  275   template<
typename _Tp, 
typename _Ref, 
typename _Ptr>
 
  277     operator<(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
 
  278           const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT
 
  279     { 
return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur)
 
  280                                           : (__x._M_node < __y._M_node); }
 
  282   template<
typename _Tp, 
typename _RefL, 
typename _PtrL,
 
  283        typename _RefR, 
typename _PtrR>
 
  285     operator<(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
 
  286           const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
 
  287     { 
return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur)
 
  288                                       : (__x._M_node < __y._M_node); }
 
  290   template<
typename _Tp, 
typename _Ref, 
typename _Ptr>
 
  292     operator>(
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
 
  293           const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT
 
  294     { 
return __y < __x; }
 
  296   template<
typename _Tp, 
typename _RefL, 
typename _PtrL,
 
  297        typename _RefR, 
typename _PtrR>
 
  299     operator>(
const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
 
  300           const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
 
  301     { 
return __y < __x; }
 
  303   template<
typename _Tp, 
typename _Ref, 
typename _Ptr>
 
  305     operator<=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
 
  306            const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT
 
  307     { 
return !(__y < __x); }
 
  309   template<
typename _Tp, 
typename _RefL, 
typename _PtrL,
 
  310        typename _RefR, 
typename _PtrR>
 
  312     operator<=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
 
  313            const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
 
  314     { 
return !(__y < __x); }
 
  316   template<
typename _Tp, 
typename _Ref, 
typename _Ptr>
 
  318     operator>=(
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
 
  319            const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT
 
  320     { 
return !(__x < __y); }
 
  322   template<
typename _Tp, 
typename _RefL, 
typename _PtrL,
 
  323        typename _RefR, 
typename _PtrR>
 
  325     operator>=(
const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
 
  326            const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
 
  327     { 
return !(__x < __y); }
 
  333   template<
typename _Tp, 
typename _Ref, 
typename _Ptr>
 
  334     inline typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type
 
  335     operator-(
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
 
  336           const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT
 
  338       return typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type
 
  339     (_Deque_iterator<_Tp, _Ref, _Ptr>::_S_buffer_size())
 
  340     * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first)
 
  341     + (__y._M_last - __y._M_cur);
 
  344   template<
typename _Tp, 
typename _RefL, 
typename _PtrL,
 
  345        typename _RefR, 
typename _PtrR>
 
  346     inline typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
 
  347     operator-(
const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
 
  348           const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
 
  350       return typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
 
  351     (_Deque_iterator<_Tp, _RefL, _PtrL>::_S_buffer_size())
 
  352     * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first)
 
  353     + (__y._M_last - __y._M_cur);
 
  356   template<
typename _Tp, 
typename _Ref, 
typename _Ptr>
 
  357     inline _Deque_iterator<_Tp, _Ref, _Ptr>
 
  358     operator+(ptrdiff_t __n, 
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x)
 
  360     { 
return __x + __n; }
 
  362   template<
typename _Tp>
 
  364     fill(
const _Deque_iterator<_Tp, _Tp&, _Tp*>&,
 
  365      const _Deque_iterator<_Tp, _Tp&, _Tp*>&, 
const _Tp&);
 
  367   template<
typename _Tp>
 
  368     _Deque_iterator<_Tp, _Tp&, _Tp*>
 
  369     copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
 
  370      _Deque_iterator<_Tp, const _Tp&, const _Tp*>,
 
  371      _Deque_iterator<_Tp, _Tp&, _Tp*>);
 
  373   template<
typename _Tp>
 
  374     inline _Deque_iterator<_Tp, _Tp&, _Tp*>
 
  375     copy(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
 
  376      _Deque_iterator<_Tp, _Tp&, _Tp*> __last,
 
  377      _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
 
  378     { 
return std::copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*>(__first),
 
  379                _Deque_iterator<_Tp, const _Tp&, const _Tp*>(__last),
 
  382   template<
typename _Tp>
 
  383     _Deque_iterator<_Tp, _Tp&, _Tp*>
 
  384     copy_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
 
  385           _Deque_iterator<_Tp, const _Tp&, const _Tp*>,
 
  386           _Deque_iterator<_Tp, _Tp&, _Tp*>);
 
  388   template<
typename _Tp>
 
  389     inline _Deque_iterator<_Tp, _Tp&, _Tp*>
 
  390     copy_backward(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
 
  391           _Deque_iterator<_Tp, _Tp&, _Tp*> __last,
 
  392           _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
 
  393     { 
return std::copy_backward(_Deque_iterator<_Tp,
 
  394                 const _Tp&, 
const _Tp*>(__first),
 
  396                 const _Tp&, 
const _Tp*>(__last),
 
  399 #if __cplusplus >= 201103L 
  400   template<
typename _Tp>
 
  401     _Deque_iterator<_Tp, _Tp&, _Tp*>
 
  402     move(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
 
  403      _Deque_iterator<_Tp, const _Tp&, const _Tp*>,
 
  404      _Deque_iterator<_Tp, _Tp&, _Tp*>);
 
  406   template<
typename _Tp>
 
  407     inline _Deque_iterator<_Tp, _Tp&, _Tp*>
 
  408     move(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
 
  409      _Deque_iterator<_Tp, _Tp&, _Tp*> __last,
 
  410      _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
 
  411     { 
return std::move(_Deque_iterator<_Tp, const _Tp&, const _Tp*>(__first),
 
  412                _Deque_iterator<_Tp, const _Tp&, const _Tp*>(__last),
 
  415   template<
typename _Tp>
 
  416     _Deque_iterator<_Tp, _Tp&, _Tp*>
 
  417     move_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
 
  418           _Deque_iterator<_Tp, const _Tp&, const _Tp*>,
 
  419           _Deque_iterator<_Tp, _Tp&, _Tp*>);
 
  421   template<
typename _Tp>
 
  422     inline _Deque_iterator<_Tp, _Tp&, _Tp*>
 
  423     move_backward(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
 
  424           _Deque_iterator<_Tp, _Tp&, _Tp*> __last,
 
  425           _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
 
  426     { 
return std::move_backward(_Deque_iterator<_Tp,
 
  427                 const _Tp&, 
const _Tp*>(__first),
 
  429                 const _Tp&, 
const _Tp*>(__last),
 
  443   template<
typename _Tp, 
typename _Alloc>
 
  447       typedef _Alloc                  allocator_type;
 
  450       get_allocator() 
const _GLIBCXX_NOEXCEPT
 
  451       { 
return allocator_type(_M_get_Tp_allocator()); }
 
  464       _Deque_base(
const allocator_type& __a, 
size_t __num_elements)
 
  472 #if __cplusplus >= 201103L 
  474       : _M_impl(std::move(__x._M_get_Tp_allocator()))
 
  477     if (__x._M_impl._M_map)
 
  479         std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
 
  480         std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
 
  481         std::swap(this->_M_impl._M_map, __x._M_impl._M_map);
 
  482         std::swap(this->_M_impl._M_map_size, __x._M_impl._M_map_size);
 
  493       typedef typename _Alloc::template rebind<_Tp*>::other _Map_alloc_type;
 
  495       typedef typename _Alloc::template rebind<_Tp>::other  _Tp_alloc_type;
 
  498       : 
public _Tp_alloc_type
 
  506     : _Tp_alloc_type(), _M_map(0), _M_map_size(0),
 
  507       _M_start(), _M_finish()
 
  510     _Deque_impl(
const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT
 
  511     : _Tp_alloc_type(__a), _M_map(0), _M_map_size(0),
 
  512       _M_start(), _M_finish()
 
  515 #if __cplusplus >= 201103L 
  516     _Deque_impl(_Tp_alloc_type&& __a) _GLIBCXX_NOEXCEPT
 
  517     : _Tp_alloc_type(std::move(__a)), _M_map(0), _M_map_size(0),
 
  518       _M_start(), _M_finish()
 
  524       _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT
 
  525       { 
return *
static_cast<_Tp_alloc_type*
>(&this->_M_impl); }
 
  527       const _Tp_alloc_type&
 
  528       _M_get_Tp_allocator() 
const _GLIBCXX_NOEXCEPT
 
  529       { 
return *
static_cast<const _Tp_alloc_type*
>(&this->_M_impl); }
 
  532       _M_get_map_allocator() 
const _GLIBCXX_NOEXCEPT
 
  533       { 
return _Map_alloc_type(_M_get_Tp_allocator()); }
 
  538     return _M_impl._Tp_alloc_type::allocate(__deque_buf_size(
sizeof(_Tp)));
 
  542       _M_deallocate_node(_Tp* __p) _GLIBCXX_NOEXCEPT
 
  544     _M_impl._Tp_alloc_type::deallocate(__p, __deque_buf_size(
sizeof(_Tp)));
 
  548       _M_allocate_map(
size_t __n)
 
  549       { 
return _M_get_map_allocator().allocate(__n); }
 
  552       _M_deallocate_map(_Tp** __p, 
size_t __n) _GLIBCXX_NOEXCEPT
 
  553       { _M_get_map_allocator().deallocate(__p, __n); }
 
  557       void _M_create_nodes(_Tp** __nstart, _Tp** __nfinish);
 
  558       void _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish) _GLIBCXX_NOEXCEPT;
 
  559       enum { _S_initial_map_size = 8 };
 
  564   template<
typename _Tp, 
typename _Alloc>
 
  568       if (this->_M_impl._M_map)
 
  570       _M_destroy_nodes(this->_M_impl._M_start._M_node,
 
  571                this->_M_impl._M_finish._M_node + 1);
 
  572       _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
 
  584   template<
typename _Tp, 
typename _Alloc>
 
  589       const size_t __num_nodes = (__num_elements/ __deque_buf_size(
sizeof(_Tp))
 
  592       this->_M_impl._M_map_size = 
std::max((
size_t) _S_initial_map_size,
 
  593                        size_t(__num_nodes + 2));
 
  594       this->_M_impl._M_map = _M_allocate_map(this->_M_impl._M_map_size);
 
  601       _Tp** __nstart = (this->_M_impl._M_map
 
  602             + (this->_M_impl._M_map_size - __num_nodes) / 2);
 
  603       _Tp** __nfinish = __nstart + __num_nodes;
 
  606     { _M_create_nodes(__nstart, __nfinish); }
 
  609       _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
 
  610       this->_M_impl._M_map = 0;
 
  611       this->_M_impl._M_map_size = 0;
 
  612       __throw_exception_again;
 
  615       this->_M_impl._M_start._M_set_node(__nstart);
 
  616       this->_M_impl._M_finish._M_set_node(__nfinish - 1);
 
  617       this->_M_impl._M_start._M_cur = _M_impl._M_start._M_first;
 
  618       this->_M_impl._M_finish._M_cur = (this->_M_impl._M_finish._M_first
 
  620                     % __deque_buf_size(
sizeof(_Tp)));
 
  623   template<
typename _Tp, 
typename _Alloc>
 
  631       for (__cur = __nstart; __cur < __nfinish; ++__cur)
 
  632         *__cur = this->_M_allocate_node();
 
  636       _M_destroy_nodes(__nstart, __cur);
 
  637       __throw_exception_again;
 
  641   template<
typename _Tp, 
typename _Alloc>
 
  643     _Deque_base<_Tp, _Alloc>::
 
  644     _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish) _GLIBCXX_NOEXCEPT
 
  646       for (_Tp** __n = __nstart; __n < __nfinish; ++__n)
 
  647     _M_deallocate_node(*__n);
 
  734   template<
typename _Tp, 
typename _Alloc = std::allocator<_Tp> >
 
  738       typedef typename _Alloc::value_type        _Alloc_value_type;
 
  739       __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
 
  740       __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
 
  743       typedef typename _Base::_Tp_alloc_type     _Tp_alloc_type;
 
  746       typedef _Tp                                        value_type;
 
  747       typedef typename _Tp_alloc_type::pointer           pointer;
 
  748       typedef typename _Tp_alloc_type::const_pointer     const_pointer;
 
  749       typedef typename _Tp_alloc_type::reference         reference;
 
  750       typedef typename _Tp_alloc_type::const_reference   const_reference;
 
  755       typedef size_t                             size_type;
 
  756       typedef ptrdiff_t                          difference_type;
 
  757       typedef _Alloc                             allocator_type;
 
  760       typedef pointer*                           _Map_pointer;
 
  762       static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT
 
  763       { 
return __deque_buf_size(
sizeof(_Tp)); }
 
  767       using _Base::_M_create_nodes;
 
  768       using _Base::_M_destroy_nodes;
 
  769       using _Base::_M_allocate_node;
 
  770       using _Base::_M_deallocate_node;
 
  771       using _Base::_M_allocate_map;
 
  772       using _Base::_M_deallocate_map;
 
  773       using _Base::_M_get_Tp_allocator;
 
  779       using _Base::_M_impl;
 
  789       deque(
const allocator_type& __a = allocator_type())
 
  792 #if __cplusplus >= 201103L 
  803       { _M_default_initialize(); }
 
  813       deque(size_type __n, 
const value_type& __value,
 
  814         const allocator_type& __a = allocator_type())
 
  827       deque(size_type __n, 
const value_type& __value = value_type(),
 
  828         const allocator_type& __a = allocator_type())
 
  841       : 
_Base(__x._M_get_Tp_allocator(), __x.
size())
 
  842       { std::__uninitialized_copy_a(__x.
begin(), __x.
end(), 
 
  843                     this->_M_impl._M_start,
 
  844                     _M_get_Tp_allocator()); }
 
  846 #if __cplusplus >= 201103L 
  855       : 
_Base(std::move(__x)) { }
 
  869         const allocator_type& __a = allocator_type())
 
  892 #if __cplusplus >= 201103L 
  893       template<
typename _InputIterator,
 
  894            typename = std::_RequireInputIter<_InputIterator>>
 
  895         deque(_InputIterator __first, _InputIterator __last,
 
  896           const allocator_type& __a = allocator_type())
 
  898         { _M_initialize_dispatch(__first, __last, __false_type()); }
 
  900       template<
typename _InputIterator>
 
  901         deque(_InputIterator __first, _InputIterator __last,
 
  902           const allocator_type& __a = allocator_type())
 
  906       typedef typename std::__is_integer<_InputIterator>::__type _Integral;
 
  907       _M_initialize_dispatch(__first, __last, _Integral());
 
  917       { _M_destroy_data(
begin(), 
end(), _M_get_Tp_allocator()); }
 
  929 #if __cplusplus >= 201103L 
  961     this->
assign(__l.begin(), __l.end());
 
  977       assign(size_type __n, 
const value_type& __val)
 
  978       { _M_fill_assign(__n, __val); }
 
  992 #if __cplusplus >= 201103L 
  993       template<
typename _InputIterator,
 
  994            typename = std::_RequireInputIter<_InputIterator>>
 
  996         assign(_InputIterator __first, _InputIterator __last)
 
  997         { _M_assign_dispatch(__first, __last, __false_type()); }
 
  999       template<
typename _InputIterator>
 
 1001         assign(_InputIterator __first, _InputIterator __last)
 
 1003       typedef typename std::__is_integer<_InputIterator>::__type _Integral;
 
 1004       _M_assign_dispatch(__first, __last, _Integral());
 
 1008 #if __cplusplus >= 201103L 
 1022       { this->
assign(__l.begin(), __l.end()); }
 
 1028       { 
return _Base::get_allocator(); }
 
 1037       { 
return this->_M_impl._M_start; }
 
 1045       { 
return this->_M_impl._M_start; }
 
 1054       { 
return this->_M_impl._M_finish; }
 
 1063       { 
return this->_M_impl._M_finish; }
 
 1079       const_reverse_iterator
 
 1097       const_reverse_iterator
 
 1101 #if __cplusplus >= 201103L 
 1108       { 
return this->_M_impl._M_start; }
 
 1117       { 
return this->_M_impl._M_finish; }
 
 1124       const_reverse_iterator
 
 1133       const_reverse_iterator
 
 1142       { 
return this->_M_impl._M_finish - this->_M_impl._M_start; }
 
 1147       { 
return _M_get_Tp_allocator().max_size(); }
 
 1149 #if __cplusplus >= 201103L 
 1162     const size_type __len = 
size();
 
 1163     if (__new_size > __len)
 
 1164       _M_default_append(__new_size - __len);
 
 1165     else if (__new_size < __len)
 
 1166       _M_erase_at_end(this->_M_impl._M_start
 
 1167               + difference_type(__new_size));
 
 1182       resize(size_type __new_size, 
const value_type& __x)
 
 1184     const size_type __len = 
size();
 
 1185     if (__new_size > __len)
 
 1186       insert(this->_M_impl._M_finish, __new_size - __len, __x);
 
 1187     else if (__new_size < __len)
 
 1188       _M_erase_at_end(this->_M_impl._M_start
 
 1189               + difference_type(__new_size));
 
 1204       resize(size_type __new_size, value_type __x = value_type())
 
 1206     const size_type __len = 
size();
 
 1207     if (__new_size > __len)
 
 1208       insert(this->_M_impl._M_finish, __new_size - __len, __x);
 
 1209     else if (__new_size < __len)
 
 1210       _M_erase_at_end(this->_M_impl._M_start
 
 1211               + difference_type(__new_size));
 
 1215 #if __cplusplus >= 201103L 
 1219       { _M_shrink_to_fit(); }
 
 1228       { 
return this->_M_impl._M_finish == this->_M_impl._M_start; }
 
 1244       { 
return this->_M_impl._M_start[difference_type(__n)]; }
 
 1259       { 
return this->_M_impl._M_start[difference_type(__n)]; }
 
 1266     if (__n >= this->
size())
 
 1267       __throw_out_of_range_fmt(__N(
"deque::_M_range_check: __n " 
 1268                        "(which is %zu)>= this->size() " 
 1289     return (*
this)[__n];
 
 1307     return (*
this)[__n];
 
 1316       { 
return *
begin(); }
 
 1324       { 
return *
begin(); }
 
 1363     if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first)
 
 1365         this->_M_impl.construct(this->_M_impl._M_start._M_cur - 1, __x);
 
 1366         --this->_M_impl._M_start._M_cur;
 
 1372 #if __cplusplus >= 201103L 
 1375       { emplace_front(std::move(__x)); }
 
 1377       template<
typename... _Args>
 
 1379         emplace_front(_Args&&... __args);
 
 1394     if (this->_M_impl._M_finish._M_cur
 
 1395         != this->_M_impl._M_finish._M_last - 1)
 
 1397         this->_M_impl.construct(this->_M_impl._M_finish._M_cur, __x);
 
 1398         ++this->_M_impl._M_finish._M_cur;
 
 1404 #if __cplusplus >= 201103L 
 1407       { emplace_back(std::move(__x)); }
 
 1409       template<
typename... _Args>
 
 1411         emplace_back(_Args&&... __args);
 
 1425     if (this->_M_impl._M_start._M_cur
 
 1426         != this->_M_impl._M_start._M_last - 1)
 
 1428         this->_M_impl.destroy(this->_M_impl._M_start._M_cur);
 
 1429         ++this->_M_impl._M_start._M_cur;
 
 1446     if (this->_M_impl._M_finish._M_cur
 
 1447         != this->_M_impl._M_finish._M_first)
 
 1449         --this->_M_impl._M_finish._M_cur;
 
 1450         this->_M_impl.destroy(this->_M_impl._M_finish._M_cur);
 
 1456 #if __cplusplus >= 201103L 
 1466       template<
typename... _Args>
 
 1468         emplace(const_iterator __position, _Args&&... __args);
 
 1480       insert(const_iterator __position, 
const value_type& __x);
 
 1495 #if __cplusplus >= 201103L 
 1507       { 
return emplace(__position, std::move(__x)); }
 
 1520       { 
return this->
insert(__p, __l.begin(), __l.end()); }
 
 1523 #if __cplusplus >= 201103L 
 1537     difference_type __offset = __position - 
cbegin();
 
 1538     _M_fill_insert(__position._M_const_cast(), __n, __x);
 
 1539     return begin() + __offset;
 
 1552       insert(
iterator __position, size_type __n, 
const value_type& __x)
 
 1553       { _M_fill_insert(__position, __n, __x); }
 
 1556 #if __cplusplus >= 201103L 
 1568       template<
typename _InputIterator,
 
 1569            typename = std::_RequireInputIter<_InputIterator>>
 
 1572            _InputIterator __last)
 
 1574       difference_type __offset = __position - 
cbegin();
 
 1575       _M_insert_dispatch(__position._M_const_cast(),
 
 1576                  __first, __last, __false_type());
 
 1577       return begin() + __offset;
 
 1590       template<
typename _InputIterator>
 
 1593            _InputIterator __last)
 
 1596       typedef typename std::__is_integer<_InputIterator>::__type _Integral;
 
 1597       _M_insert_dispatch(__position, __first, __last, _Integral());
 
 1615 #if __cplusplus >= 201103L 
 1616       erase(const_iterator __position)
 
 1618       erase(iterator __position)
 
 1620       { 
return _M_erase(__position._M_const_cast()); }
 
 1639 #if __cplusplus >= 201103L 
 1640       erase(const_iterator __first, const_iterator __last)
 
 1644       { 
return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }
 
 1658     std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
 
 1659     std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
 
 1660     std::swap(this->_M_impl._M_map, __x._M_impl._M_map);
 
 1661     std::swap(this->_M_impl._M_map_size, __x._M_impl._M_map_size);
 
 1665     std::__alloc_swap<_Tp_alloc_type>::_S_do_it(_M_get_Tp_allocator(),
 
 1666                             __x._M_get_Tp_allocator());
 
 1677       { _M_erase_at_end(
begin()); }
 
 1686       template<
typename _Integer>
 
 1688         _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
 
 1695       template<
typename _InputIterator>
 
 1697         _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
 
 1700       typedef typename std::iterator_traits<_InputIterator>::
 
 1701         iterator_category _IterCategory;
 
 1717       template<
typename _InputIterator>
 
 1723       template<
typename _ForwardIterator>
 
 1742 #if __cplusplus >= 201103L 
 1745       _M_default_initialize();
 
 1755       template<
typename _Integer>
 
 1757         _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
 
 1758         { _M_fill_assign(__n, __val); }
 
 1761       template<
typename _InputIterator>
 
 1763         _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
 
 1766       typedef typename std::iterator_traits<_InputIterator>::
 
 1767         iterator_category _IterCategory;
 
 1768       _M_assign_aux(__first, __last, _IterCategory());
 
 1772       template<
typename _InputIterator>
 
 1774         _M_assign_aux(_InputIterator __first, _InputIterator __last,
 
 1778       template<
typename _ForwardIterator>
 
 1780         _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
 
 1786           _ForwardIterator __mid = __first;
 
 1788           std::copy(__first, __mid, 
begin());
 
 1792         _M_erase_at_end(std::copy(__first, __last, 
begin()));
 
 1798       _M_fill_assign(size_type __n, 
const value_type& __val)
 
 1807         _M_erase_at_end(
begin() + difference_type(__n));
 
 1814 #if __cplusplus < 201103L 
 1819       template<
typename... _Args>
 
 1822       template<
typename... _Args>
 
 1838       template<
typename _Integer>
 
 1840         _M_insert_dispatch(iterator __pos,
 
 1841                _Integer __n, _Integer __x, __true_type)
 
 1842         { _M_fill_insert(__pos, __n, __x); }
 
 1845       template<
typename _InputIterator>
 
 1847         _M_insert_dispatch(iterator __pos,
 
 1848                _InputIterator __first, _InputIterator __last,
 
 1851       typedef typename std::iterator_traits<_InputIterator>::
 
 1852         iterator_category _IterCategory;
 
 1853           _M_range_insert_aux(__pos, __first, __last, _IterCategory());
 
 1857       template<
typename _InputIterator>
 
 1859         _M_range_insert_aux(iterator __pos, _InputIterator __first,
 
 1863       template<
typename _ForwardIterator>
 
 1865         _M_range_insert_aux(iterator __pos, _ForwardIterator __first,
 
 1872       _M_fill_insert(iterator __pos, size_type __n, 
const value_type& __x);
 
 1875 #if __cplusplus < 201103L 
 1877       _M_insert_aux(iterator __pos, 
const value_type& __x);
 
 1879       template<
typename... _Args>
 
 1881         _M_insert_aux(iterator __pos, _Args&&... __args);
 
 1886       _M_insert_aux(iterator __pos, size_type __n, 
const value_type& __x);
 
 1889       template<
typename _ForwardIterator>
 
 1891         _M_insert_aux(iterator __pos,
 
 1892               _ForwardIterator __first, _ForwardIterator __last,
 
 1899       _M_destroy_data_aux(iterator __first, iterator __last);
 
 1903       template<
typename _Alloc1>
 
 1905         _M_destroy_data(iterator __first, iterator __last, 
const _Alloc1&)
 
 1906         { _M_destroy_data_aux(__first, __last); }
 
 1909       _M_destroy_data(iterator __first, iterator __last,
 
 1912     if (!__has_trivial_destructor(value_type))
 
 1913       _M_destroy_data_aux(__first, __last);
 
 1918       _M_erase_at_begin(iterator __pos)
 
 1920     _M_destroy_data(
begin(), __pos, _M_get_Tp_allocator());
 
 1921     _M_destroy_nodes(this->_M_impl._M_start._M_node, __pos._M_node);
 
 1922     this->_M_impl._M_start = __pos;
 
 1928       _M_erase_at_end(iterator __pos)
 
 1930     _M_destroy_data(__pos, 
end(), _M_get_Tp_allocator());
 
 1931     _M_destroy_nodes(__pos._M_node + 1,
 
 1932              this->_M_impl._M_finish._M_node + 1);
 
 1933     this->_M_impl._M_finish = __pos;
 
 1937       _M_erase(iterator __pos);
 
 1940       _M_erase(iterator __first, iterator __last);
 
 1942 #if __cplusplus >= 201103L 
 1945       _M_default_append(size_type __n);
 
 1956     const size_type __vacancies = this->_M_impl._M_start._M_cur
 
 1957                                   - this->_M_impl._M_start._M_first;
 
 1958     if (__n > __vacancies)
 
 1960     return this->_M_impl._M_start - difference_type(__n);
 
 1966     const size_type __vacancies = (this->_M_impl._M_finish._M_last
 
 1967                        - this->_M_impl._M_finish._M_cur) - 1;
 
 1968     if (__n > __vacancies)
 
 1970     return this->_M_impl._M_finish + difference_type(__n);
 
 1992     if (__nodes_to_add + 1 > this->_M_impl._M_map_size
 
 1993         - (this->_M_impl._M_finish._M_node - this->_M_impl._M_map))
 
 2000     if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node
 
 2001                        - this->_M_impl._M_map))
 
 2021   template<
typename _Tp, 
typename _Alloc>
 
 2039   template<
typename _Tp, 
typename _Alloc>
 
 2041     operator<(const deque<_Tp, _Alloc>& __x,
 
 2044                       __y.begin(), __y.end()); }
 
 2047   template<
typename _Tp, 
typename _Alloc>
 
 2051     { 
return !(__x == __y); }
 
 2054   template<
typename _Tp, 
typename _Alloc>
 
 2058     { 
return __y < __x; }
 
 2061   template<
typename _Tp, 
typename _Alloc>
 
 2063     operator<=(const deque<_Tp, _Alloc>& __x,
 
 2065     { 
return !(__y < __x); }
 
 2068   template<
typename _Tp, 
typename _Alloc>
 
 2072     { 
return !(__x < __y); }
 
 2075   template<
typename _Tp, 
typename _Alloc>
 
 2080 #undef _GLIBCXX_DEQUE_BUF_SIZE 
 2082 _GLIBCXX_END_NAMESPACE_CONTAINER
 
const_reverse_iterator rend() const noexcept
 
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y. 
 
iterator insert(const_iterator __position, value_type &&__x)
Inserts given rvalue into deque before specified iterator. 
 
reference back() noexcept
 
size_type size() const noexcept
 
void _M_pop_back_aux()
Helper functions for push_* and pop_*. 
 
iterator begin() noexcept
 
void shrink_to_fit() noexcept
 
void push_back(const value_type &__x)
Add data to the end of the deque. 
 
void _M_reserve_map_at_front(size_type __nodes_to_add=1)
Memory-handling helpers for the major map. 
 
iterator _M_reserve_elements_at_back(size_type __n)
Memory-handling helpers for the previous internal insert functions. 
 
const_iterator cend() const noexcept
 
Forward iterators support a superset of input iterator operations. 
 
reverse_iterator rend() noexcept
 
reference operator[](size_type __n) noexcept
Subscript access to the data contained in the deque. 
 
deque(initializer_list< value_type > __l, const allocator_type &__a=allocator_type())
Builds a deque from an initializer list. 
 
deque(deque &&__x)
Deque move constructor. 
 
reference front() noexcept
 
const_reference back() const noexcept
 
const_iterator begin() const noexcept
 
const_reverse_iterator crend() const noexcept
 
deque(_InputIterator __first, _InputIterator __last, const allocator_type &__a=allocator_type())
Builds a deque from a range. 
 
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object. 
 
void _M_reserve_map_at_back(size_type __nodes_to_add=1)
Memory-handling helpers for the major map. 
 
Random-access iterators support a superset of bidirectional iterator operations. 
 
iterator insert(const_iterator __position, const value_type &__x)
Inserts given value into deque before specified iterator. 
 
iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic. 
 
deque(size_type __n, const value_type &__value, const allocator_type &__a=allocator_type())
Creates a deque with copies of an exemplar element. 
 
iterator emplace(const_iterator __position, _Args &&...__args)
Inserts an object in deque before specified iterator. 
 
reference at(size_type __n)
Provides access to the data contained in the deque. 
 
void _M_set_node(_Map_pointer __new_node) noexcept
 
const_iterator cbegin() const noexcept
 
void assign(initializer_list< value_type > __l)
Assigns an initializer list to a deque. 
 
iterator insert(const_iterator __p, initializer_list< value_type > __l)
Inserts an initializer list into the deque. 
 
const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does. 
 
void _M_new_elements_at_front(size_type __new_elements)
Memory-handling helpers for the previous internal insert functions. 
 
deque & operator=(deque &&__x) noexcept
Deque move assignment operator. 
 
deque & operator=(initializer_list< value_type > __l)
Assigns an initializer list to a deque. 
 
void _M_range_initialize(_InputIterator __first, _InputIterator __last, std::input_iterator_tag)
Fills the deque with whatever is in [first,last). 
 
void _M_initialize_map(size_t)
Layout storage. 
 
void _M_new_elements_at_back(size_type __new_elements)
Memory-handling helpers for the previous internal insert functions. 
 
bool equal(_II1 __first1, _II1 __last1, _II2 __first2)
Tests a range for element-wise equality. 
 
void pop_back() noexcept
Removes last element. 
 
const_reverse_iterator rbegin() const noexcept
 
void _M_pop_front_aux()
Helper functions for push_* and pop_*. 
 
const_reference front() const noexcept
 
void resize(size_type __new_size)
Resizes the deque to the specified number of elements. 
 
#define _GLIBCXX_DEQUE_BUF_SIZE
This function controls the size of memory nodes. 
 
deque & operator=(const deque &__x)
Deque assignment operator. 
 
void _M_fill_initialize(const value_type &__value)
Fills the deque with copies of value. 
 
reverse_iterator rbegin() noexcept
 
void swap(deque &__x) noexcept
Swaps data with another deque. 
 
size_type max_size() const noexcept
 
iterator _M_reserve_elements_at_front(size_type __n)
Memory-handling helpers for the previous internal insert functions. 
 
complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y. 
 
void _M_range_check(size_type __n) const 
Safety check used only from at(). 
 
void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic. 
 
The standard allocator, as per [20.4]. 
 
void pop_front() noexcept
Removes first element. 
 
void resize(size_type __new_size, const value_type &__x)
Resizes the deque to the specified number of elements. 
 
const_reference at(size_type __n) const 
Provides access to the data contained in the deque. 
 
void swap(function< _Res(_Args...)> &__x, function< _Res(_Args...)> &__y)
Swap the targets of two polymorphic function object wrappers. 
 
void _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front)
Memory-handling helpers for the major map. 
 
void _M_push_back_aux(_Args &&...__args)
Helper functions for push_* and pop_*. 
 
void _M_push_front_aux(_Args &&...__args)
Helper functions for push_* and pop_*. 
 
const_reverse_iterator crbegin() const noexcept
 
deque(const deque &__x)
Deque copy constructor. 
 
void assign(size_type __n, const value_type &__val)
Assigns a given value to a deque. 
 
void assign(_InputIterator __first, _InputIterator __last)
Assigns a range to a deque. 
 
bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, _Compare __comp)
Performs dictionary comparison on ranges. 
 
iterator insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
Inserts a range into the deque. 
 
iterator insert(const_iterator __position, size_type __n, const value_type &__x)
Inserts a number of copies of given data into the deque. 
 
void push_front(const value_type &__x)
Add data to the front of the deque. 
 
const_iterator end() const noexcept
 
A standard container using fixed-size memory allocation and constant-time manipulation of elements at...
 
bool empty() const noexcept
 
const_reference operator[](size_type __n) const noexcept
Subscript access to the data contained in the deque.