29 #ifndef _GLIBCXX_DEBUG_DEQUE
30 #define _GLIBCXX_DEBUG_DEQUE 1
37 namespace std _GLIBCXX_VISIBILITY(default)
42 template<
typename _Tp,
typename _Allocator = std::allocator<_Tp> >
45 deque<_Tp, _Allocator>, _Allocator,
46 __gnu_debug::_Safe_sequence>,
47 public _GLIBCXX_STD_C::deque<_Tp, _Allocator>
49 typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator>
_Base;
58 typedef typename _Base::reference reference;
59 typedef typename _Base::const_reference const_reference;
66 typedef typename _Base::size_type size_type;
67 typedef typename _Base::difference_type difference_type;
69 typedef _Tp value_type;
70 typedef _Allocator allocator_type;
71 typedef typename _Base::pointer pointer;
72 typedef typename _Base::const_pointer const_pointer;
78 #if __cplusplus < 201103L
95 :
_Safe(std::move(__d)),
_Base(std::move(__d), __a) { }
98 const allocator_type& __a = allocator_type())
105 deque(
const _Allocator& __a)
108 #if __cplusplus >= 201103L
110 deque(size_type __n,
const _Allocator& __a = _Allocator())
111 :
_Base(__n, __a) { }
113 deque(size_type __n,
const _Tp& __value,
114 const _Allocator& __a = _Allocator())
115 :
_Base(__n, __value, __a) { }
118 deque(size_type __n,
const _Tp& __value = _Tp(),
119 const _Allocator& __a = _Allocator())
120 :
_Base(__n, __value, __a) { }
123 #if __cplusplus >= 201103L
124 template<
class _InputIterator,
125 typename = std::_RequireInputIter<_InputIterator>>
127 template<
class _InputIterator>
129 deque(_InputIterator __first, _InputIterator __last,
130 const _Allocator& __a = _Allocator())
136 deque(
const _Base& __x)
139 #if __cplusplus < 201103L
141 operator=(
const deque& __x)
143 this->_M_safe() = __x;
149 operator=(
const deque&) =
default;
152 operator=(deque&&) =
default;
163 #if __cplusplus >= 201103L
164 template<
class _InputIterator,
165 typename = std::_RequireInputIter<_InputIterator>>
167 template<
class _InputIterator>
170 assign(_InputIterator __first, _InputIterator __last)
172 __glibcxx_check_valid_range(__first, __last);
179 assign(size_type __n,
const _Tp& __t)
181 _Base::assign(__n, __t);
185 #if __cplusplus >= 201103L
194 using _Base::get_allocator;
198 begin() _GLIBCXX_NOEXCEPT
199 {
return iterator(_Base::begin(),
this); }
202 begin()
const _GLIBCXX_NOEXCEPT
206 end() _GLIBCXX_NOEXCEPT
207 {
return iterator(_Base::end(),
this); }
210 end()
const _GLIBCXX_NOEXCEPT
214 rbegin() _GLIBCXX_NOEXCEPT
218 rbegin()
const _GLIBCXX_NOEXCEPT
222 rend() _GLIBCXX_NOEXCEPT
226 rend()
const _GLIBCXX_NOEXCEPT
229 #if __cplusplus >= 201103L
231 cbegin()
const noexcept
235 cend()
const noexcept
239 crbegin()
const noexcept
243 crend()
const noexcept
249 _M_invalidate_after_nth(difference_type __n)
258 using _Base::max_size;
260 #if __cplusplus >= 201103L
262 resize(size_type __sz)
264 bool __invalidate_all = __sz > this->size();
265 if (__sz < this->size())
266 this->_M_invalidate_after_nth(__sz);
270 if (__invalidate_all)
275 resize(size_type __sz,
const _Tp& __c)
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)
288 resize(size_type __sz, _Tp __c = _Tp())
290 bool __invalidate_all = __sz > this->size();
291 if (__sz < this->size())
292 this->_M_invalidate_after_nth(__sz);
294 _Base::resize(__sz, __c);
296 if (__invalidate_all)
301 #if __cplusplus >= 201103L
303 shrink_to_fit() noexcept
305 if (_Base::_M_shrink_to_fit())
314 operator[](size_type __n) _GLIBCXX_NOEXCEPT
316 __glibcxx_check_subscript(__n);
317 return _M_base()[__n];
321 operator[](size_type __n)
const _GLIBCXX_NOEXCEPT
323 __glibcxx_check_subscript(__n);
324 return _M_base()[__n];
330 front() _GLIBCXX_NOEXCEPT
332 __glibcxx_check_nonempty();
333 return _Base::front();
337 front()
const _GLIBCXX_NOEXCEPT
339 __glibcxx_check_nonempty();
340 return _Base::front();
344 back() _GLIBCXX_NOEXCEPT
346 __glibcxx_check_nonempty();
347 return _Base::back();
351 back()
const _GLIBCXX_NOEXCEPT
353 __glibcxx_check_nonempty();
354 return _Base::back();
359 push_front(
const _Tp& __x)
361 _Base::push_front(__x);
366 push_back(
const _Tp& __x)
368 _Base::push_back(__x);
372 #if __cplusplus >= 201103L
374 push_front(_Tp&& __x)
375 { emplace_front(std::move(__x)); }
379 { emplace_back(std::move(__x)); }
381 template<
typename... _Args>
383 emplace_front(_Args&&... __args)
385 _Base::emplace_front(std::forward<_Args>(__args)...);
389 template<
typename... _Args>
391 emplace_back(_Args&&... __args)
393 _Base::emplace_back(std::forward<_Args>(__args)...);
397 template<
typename... _Args>
403 std::forward<_Args>(__args)...);
410 #if __cplusplus >= 201103L
413 insert(
iterator __position,
const _Tp& __x)
422 #if __cplusplus >= 201103L
425 {
return emplace(__position, std::move(__x)); }
437 #if __cplusplus >= 201103L
448 insert(
iterator __position, size_type __n,
const _Tp& __x)
451 _Base::insert(__position.
base(), __n, __x);
456 #if __cplusplus >= 201103L
457 template<
class _InputIterator,
458 typename = std::_RequireInputIter<_InputIterator>>
461 _InputIterator __first, _InputIterator __last)
471 template<
class _InputIterator>
474 _InputIterator __first, _InputIterator __last)
484 pop_front() _GLIBCXX_NOEXCEPT
486 __glibcxx_check_nonempty();
492 pop_back() _GLIBCXX_NOEXCEPT
494 __glibcxx_check_nonempty();
500 #if __cplusplus >= 201103L
507 #if __cplusplus >= 201103L
512 if (__victim == _Base::begin() || __victim == _Base::end() - 1)
515 return iterator(_Base::erase(__victim),
this);
526 #if __cplusplus >= 201103L
536 if (__first.
base() == __last.
base())
537 #
if __cplusplus >= 201103L
542 else if (__first.
base() == _Base::begin()
543 || __last.
base() == _Base::end())
547 __position != __last.
base(); ++__position)
559 __throw_exception_again;
573 #if __cplusplus >= 201103L
574 noexcept( noexcept(declval<_Base>().swap(__x)) )
582 clear() _GLIBCXX_NOEXCEPT
589 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
592 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
595 template<
typename _Tp,
typename _Alloc>
599 {
return __lhs._M_base() == __rhs._M_base(); }
601 template<
typename _Tp,
typename _Alloc>
605 {
return __lhs._M_base() != __rhs._M_base(); }
607 template<
typename _Tp,
typename _Alloc>
609 operator<(const deque<_Tp, _Alloc>& __lhs,
610 const deque<_Tp, _Alloc>& __rhs)
611 {
return __lhs._M_base() < __rhs._M_base(); }
613 template<
typename _Tp,
typename _Alloc>
615 operator<=(const deque<_Tp, _Alloc>& __lhs,
616 const deque<_Tp, _Alloc>& __rhs)
617 {
return __lhs._M_base() <= __rhs._M_base(); }
619 template<
typename _Tp,
typename _Alloc>
621 operator>=(
const deque<_Tp, _Alloc>& __lhs,
622 const deque<_Tp, _Alloc>& __rhs)
623 {
return __lhs._M_base() >= __rhs._M_base(); }
625 template<
typename _Tp,
typename _Alloc>
627 operator>(
const deque<_Tp, _Alloc>& __lhs,
628 const deque<_Tp, _Alloc>& __rhs)
629 {
return __lhs._M_base() > __rhs._M_base(); }
631 template<
typename _Tp,
typename _Alloc>
633 swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
634 { __lhs.swap(__rhs); }
Base class for constructing a safe sequence type that tracks iterators that reference it...
#define __glibcxx_check_insert_range(_Position, _First, _Last)
void _M_revalidate_singular()
#define __glibcxx_check_erase(_Position)
_Iterator & base() noexcept
Return the underlying iterator.
void _M_invalidate_if(_Predicate __pred)
void _M_detach_singular()
void _M_invalidate_all() const
#define __glibcxx_check_erase_range(_First, _Last)
A standard container using fixed-size memory allocation and constant-time manipulation of elements at...
Safe class dealing with some allocator dependent operations.
Class std::deque with safety/checking/debug instrumentation.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
#define __glibcxx_check_insert(_Position)