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;
72 deque(
const _Allocator& __a = _Allocator())
75 #if __cplusplus >= 201103L
80 deque(size_type __n,
const _Tp& __value,
81 const _Allocator& __a = _Allocator())
82 :
_Base(__n, __value, __a) { }
85 deque(size_type __n,
const _Tp& __value = _Tp(),
86 const _Allocator& __a = _Allocator())
87 :
_Base(__n, __value, __a) { }
90 #if __cplusplus >= 201103L
91 template<
class _InputIterator,
92 typename = std::_RequireInputIter<_InputIterator>>
94 template<
class _InputIterator>
96 deque(_InputIterator __first, _InputIterator __last,
97 const _Allocator& __a = _Allocator())
103 deque(
const deque& __x)
106 deque(
const _Base& __x)
109 #if __cplusplus >= 201103L
111 :
_Base(std::move(__x))
115 const allocator_type& __a = allocator_type())
116 :
_Base(__l, __a) { }
119 ~deque() _GLIBCXX_NOEXCEPT { }
122 operator=(
const deque& __x)
124 *
static_cast<_Base*
>(
this) = __x;
125 this->_M_invalidate_all();
129 #if __cplusplus >= 201103L
131 operator=(deque&& __x) noexcept
135 __glibcxx_check_self_move_assign(__x);
144 *
static_cast<_Base*
>(
this) = __l;
145 this->_M_invalidate_all();
150 #if __cplusplus >= 201103L
151 template<
class _InputIterator,
152 typename = std::_RequireInputIter<_InputIterator>>
154 template<
class _InputIterator>
157 assign(_InputIterator __first, _InputIterator __last)
159 __glibcxx_check_valid_range(__first, __last);
162 this->_M_invalidate_all();
166 assign(size_type __n,
const _Tp& __t)
168 _Base::assign(__n, __t);
169 this->_M_invalidate_all();
172 #if __cplusplus >= 201103L
177 this->_M_invalidate_all();
181 using _Base::get_allocator;
185 begin() _GLIBCXX_NOEXCEPT
186 {
return iterator(_Base::begin(),
this); }
189 begin()
const _GLIBCXX_NOEXCEPT
193 end() _GLIBCXX_NOEXCEPT
194 {
return iterator(_Base::end(),
this); }
197 end()
const _GLIBCXX_NOEXCEPT
201 rbegin() _GLIBCXX_NOEXCEPT
205 rbegin()
const _GLIBCXX_NOEXCEPT
209 rend() _GLIBCXX_NOEXCEPT
213 rend()
const _GLIBCXX_NOEXCEPT
216 #if __cplusplus >= 201103L
218 cbegin()
const noexcept
222 cend()
const noexcept
226 crbegin()
const noexcept
230 crend()
const noexcept
236 _M_invalidate_after_nth(difference_type __n)
245 using _Base::max_size;
247 #if __cplusplus >= 201103L
249 resize(size_type __sz)
251 bool __invalidate_all = __sz > this->
size();
252 if (__sz < this->
size())
253 this->_M_invalidate_after_nth(__sz);
257 if (__invalidate_all)
258 this->_M_invalidate_all();
262 resize(size_type __sz,
const _Tp& __c)
264 bool __invalidate_all = __sz > this->
size();
265 if (__sz < this->
size())
266 this->_M_invalidate_after_nth(__sz);
268 _Base::resize(__sz, __c);
270 if (__invalidate_all)
271 this->_M_invalidate_all();
275 resize(size_type __sz, _Tp __c = _Tp())
277 bool __invalidate_all = __sz > this->
size();
278 if (__sz < this->
size())
279 this->_M_invalidate_after_nth(__sz);
281 _Base::resize(__sz, __c);
283 if (__invalidate_all)
284 this->_M_invalidate_all();
288 #if __cplusplus >= 201103L
290 shrink_to_fit() noexcept
292 if (_Base::_M_shrink_to_fit())
293 this->_M_invalidate_all();
301 operator[](size_type __n) _GLIBCXX_NOEXCEPT
303 __glibcxx_check_subscript(__n);
304 return _M_base()[__n];
308 operator[](size_type __n)
const _GLIBCXX_NOEXCEPT
310 __glibcxx_check_subscript(__n);
311 return _M_base()[__n];
317 front() _GLIBCXX_NOEXCEPT
319 __glibcxx_check_nonempty();
320 return _Base::front();
324 front()
const _GLIBCXX_NOEXCEPT
326 __glibcxx_check_nonempty();
327 return _Base::front();
331 back() _GLIBCXX_NOEXCEPT
333 __glibcxx_check_nonempty();
334 return _Base::back();
338 back()
const _GLIBCXX_NOEXCEPT
340 __glibcxx_check_nonempty();
341 return _Base::back();
346 push_front(
const _Tp& __x)
348 _Base::push_front(__x);
349 this->_M_invalidate_all();
353 push_back(
const _Tp& __x)
355 _Base::push_back(__x);
356 this->_M_invalidate_all();
359 #if __cplusplus >= 201103L
361 push_front(_Tp&& __x)
362 { emplace_front(std::move(__x)); }
366 { emplace_back(std::move(__x)); }
368 template<
typename... _Args>
370 emplace_front(_Args&&... __args)
372 _Base::emplace_front(std::forward<_Args>(__args)...);
373 this->_M_invalidate_all();
376 template<
typename... _Args>
378 emplace_back(_Args&&... __args)
380 _Base::emplace_back(std::forward<_Args>(__args)...);
381 this->_M_invalidate_all();
384 template<
typename... _Args>
390 std::forward<_Args>(__args)...);
391 this->_M_invalidate_all();
397 #if __cplusplus >= 201103L
400 insert(
iterator __position,
const _Tp& __x)
405 this->_M_invalidate_all();
409 #if __cplusplus >= 201103L
412 {
return emplace(__position, std::move(__x)); }
419 this->_M_invalidate_all();
424 #if __cplusplus >= 201103L
430 this->_M_invalidate_all();
435 insert(
iterator __position, size_type __n,
const _Tp& __x)
438 _Base::insert(__position.
base(), __n, __x);
439 this->_M_invalidate_all();
443 #if __cplusplus >= 201103L
444 template<
class _InputIterator,
445 typename = std::_RequireInputIter<_InputIterator>>
448 _InputIterator __first, _InputIterator __last)
454 this->_M_invalidate_all();
458 template<
class _InputIterator>
461 _InputIterator __first, _InputIterator __last)
466 this->_M_invalidate_all();
471 pop_front() _GLIBCXX_NOEXCEPT
473 __glibcxx_check_nonempty();
479 pop_back() _GLIBCXX_NOEXCEPT
481 __glibcxx_check_nonempty();
487 #if __cplusplus >= 201103L
494 #if __cplusplus >= 201103L
499 if (__victim == _Base::begin() || __victim == _Base::end() - 1)
502 return iterator(_Base::erase(__victim),
this);
507 this->_M_invalidate_all();
513 #if __cplusplus >= 201103L
523 if (__first.
base() == __last.
base())
524 #
if __cplusplus >= 201103L
529 else if (__first.
base() == _Base::begin()
530 || __last.
base() == _Base::end())
534 __position != __last.
base(); ++__position)
546 __throw_exception_again;
553 this->_M_invalidate_all();
559 swap(deque& __x) _GLIBCXX_NOEXCEPT
566 clear() _GLIBCXX_NOEXCEPT
569 this->_M_invalidate_all();
573 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
576 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
579 template<
typename _Tp,
typename _Alloc>
583 {
return __lhs._M_base() == __rhs._M_base(); }
585 template<
typename _Tp,
typename _Alloc>
589 {
return __lhs._M_base() != __rhs._M_base(); }
591 template<
typename _Tp,
typename _Alloc>
593 operator<(const deque<_Tp, _Alloc>& __lhs,
594 const deque<_Tp, _Alloc>& __rhs)
595 {
return __lhs._M_base() < __rhs._M_base(); }
597 template<
typename _Tp,
typename _Alloc>
599 operator<=(const deque<_Tp, _Alloc>& __lhs,
600 const deque<_Tp, _Alloc>& __rhs)
601 {
return __lhs._M_base() <= __rhs._M_base(); }
603 template<
typename _Tp,
typename _Alloc>
605 operator>=(
const deque<_Tp, _Alloc>& __lhs,
606 const deque<_Tp, _Alloc>& __rhs)
607 {
return __lhs._M_base() >= __rhs._M_base(); }
609 template<
typename _Tp,
typename _Alloc>
611 operator>(
const deque<_Tp, _Alloc>& __lhs,
612 const deque<_Tp, _Alloc>& __rhs)
613 {
return __lhs._M_base() > __rhs._M_base(); }
615 template<
typename _Tp,
typename _Alloc>
617 swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
618 { __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.
_Iterator base() const noexcept
Return the underlying iterator.
#define __glibcxx_check_erase(_Position)
void swap(function< _Res(_Args...)> &__x, function< _Res(_Args...)> &__y)
Swap the targets of two polymorphic function object wrappers.
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)
A standard container using fixed-size memory allocation and constant-time manipulation of elements at...
#define __glibcxx_check_erase_range(_First, _Last)