29 #ifndef _GLIBCXX_DEBUG_DEQUE
30 #define _GLIBCXX_DEBUG_DEQUE 1
36 namespace std _GLIBCXX_VISIBILITY(default)
41 template<
typename _Tp,
typename _Allocator = std::allocator<_Tp> >
43 :
public _GLIBCXX_STD_C::deque<_Tp, _Allocator>,
46 typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator>
_Base;
52 typedef typename _Base::reference reference;
53 typedef typename _Base::const_reference const_reference;
60 typedef typename _Base::size_type size_type;
61 typedef typename _Base::difference_type difference_type;
63 typedef _Tp value_type;
64 typedef _Allocator allocator_type;
65 typedef typename _Base::pointer pointer;
66 typedef typename _Base::const_pointer const_pointer;
75 deque(
const _Allocator& __a)
78 #if __cplusplus >= 201103L
83 deque(size_type __n,
const _Tp& __value,
84 const _Allocator& __a = _Allocator())
85 :
_Base(__n, __value, __a) { }
88 deque(size_type __n,
const _Tp& __value = _Tp(),
89 const _Allocator& __a = _Allocator())
90 :
_Base(__n, __value, __a) { }
93 #if __cplusplus >= 201103L
94 template<
class _InputIterator,
95 typename = std::_RequireInputIter<_InputIterator>>
97 template<
class _InputIterator>
99 deque(_InputIterator __first, _InputIterator __last,
100 const _Allocator& __a = _Allocator())
106 deque(
const deque& __x)
109 deque(
const _Base& __x)
112 #if __cplusplus >= 201103L
114 :
_Base(std::move(__x))
118 const allocator_type& __a = allocator_type())
119 :
_Base(__l, __a) { }
122 ~deque() _GLIBCXX_NOEXCEPT { }
125 operator=(
const deque& __x)
127 *
static_cast<_Base*
>(
this) = __x;
132 #if __cplusplus >= 201103L
134 operator=(deque&& __x) noexcept
138 __glibcxx_check_self_move_assign(__x);
147 *
static_cast<_Base*
>(
this) = __l;
153 #if __cplusplus >= 201103L
154 template<
class _InputIterator,
155 typename = std::_RequireInputIter<_InputIterator>>
157 template<
class _InputIterator>
160 assign(_InputIterator __first, _InputIterator __last)
162 __glibcxx_check_valid_range(__first, __last);
169 assign(size_type __n,
const _Tp& __t)
171 _Base::assign(__n, __t);
175 #if __cplusplus >= 201103L
184 using _Base::get_allocator;
188 begin() _GLIBCXX_NOEXCEPT
189 {
return iterator(_Base::begin(),
this); }
192 begin()
const _GLIBCXX_NOEXCEPT
196 end() _GLIBCXX_NOEXCEPT
197 {
return iterator(_Base::end(),
this); }
200 end()
const _GLIBCXX_NOEXCEPT
204 rbegin() _GLIBCXX_NOEXCEPT
208 rbegin()
const _GLIBCXX_NOEXCEPT
212 rend() _GLIBCXX_NOEXCEPT
216 rend()
const _GLIBCXX_NOEXCEPT
219 #if __cplusplus >= 201103L
221 cbegin()
const noexcept
225 cend()
const noexcept
229 crbegin()
const noexcept
233 crend()
const noexcept
239 _M_invalidate_after_nth(difference_type __n)
248 using _Base::max_size;
250 #if __cplusplus >= 201103L
252 resize(size_type __sz)
254 bool __invalidate_all = __sz > this->
size();
255 if (__sz < this->
size())
256 this->_M_invalidate_after_nth(__sz);
260 if (__invalidate_all)
265 resize(size_type __sz,
const _Tp& __c)
267 bool __invalidate_all = __sz > this->
size();
268 if (__sz < this->
size())
269 this->_M_invalidate_after_nth(__sz);
271 _Base::resize(__sz, __c);
273 if (__invalidate_all)
278 resize(size_type __sz, _Tp __c = _Tp())
280 bool __invalidate_all = __sz > this->
size();
281 if (__sz < this->
size())
282 this->_M_invalidate_after_nth(__sz);
284 _Base::resize(__sz, __c);
286 if (__invalidate_all)
291 #if __cplusplus >= 201103L
293 shrink_to_fit() noexcept
295 if (_Base::_M_shrink_to_fit())
304 operator[](size_type __n) _GLIBCXX_NOEXCEPT
306 __glibcxx_check_subscript(__n);
307 return _M_base()[__n];
311 operator[](size_type __n)
const _GLIBCXX_NOEXCEPT
313 __glibcxx_check_subscript(__n);
314 return _M_base()[__n];
320 front() _GLIBCXX_NOEXCEPT
322 __glibcxx_check_nonempty();
323 return _Base::front();
327 front()
const _GLIBCXX_NOEXCEPT
329 __glibcxx_check_nonempty();
330 return _Base::front();
334 back() _GLIBCXX_NOEXCEPT
336 __glibcxx_check_nonempty();
337 return _Base::back();
341 back()
const _GLIBCXX_NOEXCEPT
343 __glibcxx_check_nonempty();
344 return _Base::back();
349 push_front(
const _Tp& __x)
351 _Base::push_front(__x);
356 push_back(
const _Tp& __x)
358 _Base::push_back(__x);
362 #if __cplusplus >= 201103L
364 push_front(_Tp&& __x)
365 { emplace_front(std::move(__x)); }
369 { emplace_back(std::move(__x)); }
371 template<
typename... _Args>
373 emplace_front(_Args&&... __args)
375 _Base::emplace_front(std::forward<_Args>(__args)...);
379 template<
typename... _Args>
381 emplace_back(_Args&&... __args)
383 _Base::emplace_back(std::forward<_Args>(__args)...);
387 template<
typename... _Args>
393 std::forward<_Args>(__args)...);
400 #if __cplusplus >= 201103L
403 insert(
iterator __position,
const _Tp& __x)
412 #if __cplusplus >= 201103L
415 {
return emplace(__position, std::move(__x)); }
427 #if __cplusplus >= 201103L
438 insert(
iterator __position, size_type __n,
const _Tp& __x)
441 _Base::insert(__position.
base(), __n, __x);
446 #if __cplusplus >= 201103L
447 template<
class _InputIterator,
448 typename = std::_RequireInputIter<_InputIterator>>
451 _InputIterator __first, _InputIterator __last)
461 template<
class _InputIterator>
464 _InputIterator __first, _InputIterator __last)
474 pop_front() _GLIBCXX_NOEXCEPT
476 __glibcxx_check_nonempty();
482 pop_back() _GLIBCXX_NOEXCEPT
484 __glibcxx_check_nonempty();
490 #if __cplusplus >= 201103L
497 #if __cplusplus >= 201103L
502 if (__victim == _Base::begin() || __victim == _Base::end() - 1)
505 return iterator(_Base::erase(__victim),
this);
516 #if __cplusplus >= 201103L
526 if (__first.
base() == __last.
base())
527 #
if __cplusplus >= 201103L
532 else if (__first.
base() == _Base::begin()
533 || __last.
base() == _Base::end())
537 __position != __last.
base(); ++__position)
549 __throw_exception_again;
562 swap(deque& __x) _GLIBCXX_NOEXCEPT
569 clear() _GLIBCXX_NOEXCEPT
576 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
579 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
582 template<
typename _Tp,
typename _Alloc>
586 {
return __lhs._M_base() == __rhs._M_base(); }
588 template<
typename _Tp,
typename _Alloc>
592 {
return __lhs._M_base() != __rhs._M_base(); }
594 template<
typename _Tp,
typename _Alloc>
596 operator<(const deque<_Tp, _Alloc>& __lhs,
597 const deque<_Tp, _Alloc>& __rhs)
598 {
return __lhs._M_base() < __rhs._M_base(); }
600 template<
typename _Tp,
typename _Alloc>
602 operator<=(const deque<_Tp, _Alloc>& __lhs,
603 const deque<_Tp, _Alloc>& __rhs)
604 {
return __lhs._M_base() <= __rhs._M_base(); }
606 template<
typename _Tp,
typename _Alloc>
608 operator>=(
const deque<_Tp, _Alloc>& __lhs,
609 const deque<_Tp, _Alloc>& __rhs)
610 {
return __lhs._M_base() >= __rhs._M_base(); }
612 template<
typename _Tp,
typename _Alloc>
614 operator>(
const deque<_Tp, _Alloc>& __lhs,
615 const deque<_Tp, _Alloc>& __rhs)
616 {
return __lhs._M_base() > __rhs._M_base(); }
618 template<
typename _Tp,
typename _Alloc>
620 swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
621 { __lhs.swap(__rhs); }
void _M_revalidate_singular()
#define __glibcxx_check_insert_range(_Position, _First, _Last)
void _M_swap(_Safe_sequence_base &__x)
void _M_invalidate_if(_Predicate __pred)
#define __glibcxx_check_insert(_Position)
void _M_detach_singular()
constexpr size_t size() const noexcept
Returns the total number of bits.
void _M_invalidate_all() const
A standard container using fixed-size memory allocation and constant-time manipulation of elements at...
_Iterator base() const noexcept
Return the underlying iterator.
#define __glibcxx_check_erase(_Position)
Base class for constructing a safe sequence type that tracks iterators that reference it...
Class std::deque with safety/checking/debug instrumentation.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
#define __glibcxx_check_erase_range(_First, _Last)