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
82 deque(
const deque& __x)
88 deque(
const deque&) =
default;
89 deque(deque&&) =
default;
91 deque(
const deque& __d,
const _Allocator& __a)
94 deque(deque&& __d,
const _Allocator& __a)
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
203 {
return const_iterator(_Base::begin(),
this); }
206 end() _GLIBCXX_NOEXCEPT
207 {
return iterator(_Base::end(),
this); }
210 end()
const _GLIBCXX_NOEXCEPT
211 {
return const_iterator(_Base::end(),
this); }
214 rbegin() _GLIBCXX_NOEXCEPT
215 {
return reverse_iterator(end()); }
217 const_reverse_iterator
218 rbegin()
const _GLIBCXX_NOEXCEPT
219 {
return const_reverse_iterator(end()); }
222 rend() _GLIBCXX_NOEXCEPT
223 {
return reverse_iterator(begin()); }
225 const_reverse_iterator
226 rend()
const _GLIBCXX_NOEXCEPT
227 {
return const_reverse_iterator(begin()); }
229 #if __cplusplus >= 201103L
231 cbegin()
const noexcept
232 {
return const_iterator(_Base::begin(),
this); }
235 cend()
const noexcept
236 {
return const_iterator(_Base::end(),
this); }
238 const_reverse_iterator
239 crbegin()
const noexcept
240 {
return const_reverse_iterator(end()); }
242 const_reverse_iterator
243 crend()
const noexcept
244 {
return const_reverse_iterator(begin()); }
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>
399 emplace(const_iterator __position, _Args&&... __args)
402 _Base_iterator __res = _Base::emplace(__position.
base(),
403 std::forward<_Args>(__args)...);
405 return iterator(__res,
this);
410 #if __cplusplus >= 201103L
411 insert(const_iterator __position,
const _Tp& __x)
413 insert(iterator __position,
const _Tp& __x)
417 _Base_iterator __res = _Base::insert(__position.
base(), __x);
419 return iterator(__res,
this);
422 #if __cplusplus >= 201103L
424 insert(const_iterator __position, _Tp&& __x)
425 {
return emplace(__position, std::move(__x)); }
431 _Base_iterator __res = _Base::insert(__position.
base(), __l);
433 return iterator(__res,
this);
437 #if __cplusplus >= 201103L
439 insert(const_iterator __position, size_type __n,
const _Tp& __x)
442 _Base_iterator __res = _Base::insert(__position.
base(), __n, __x);
444 return iterator(__res,
this);
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>>
460 insert(const_iterator __position,
461 _InputIterator __first, _InputIterator __last)
464 _Base_iterator __res = _Base::insert(__position.
base(),
468 return iterator(__res,
this);
471 template<
class _InputIterator>
473 insert(iterator __position,
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
501 erase(const_iterator __position)
503 erase(iterator __position)
507 #if __cplusplus >= 201103L
508 _Base_const_iterator __victim = __position.
base();
510 _Base_iterator __victim = __position.
base();
512 if (__victim == _Base::begin() || __victim == _Base::end() - 1)
515 return iterator(_Base::erase(__victim),
this);
519 _Base_iterator __res = _Base::erase(__victim);
521 return iterator(__res,
this);
526 #if __cplusplus >= 201103L
527 erase(const_iterator __first, const_iterator __last)
529 erase(iterator __first, iterator __last)
536 if (__first.
base() == __last.
base())
537 #
if __cplusplus >= 201103L
538 return iterator(__first.
base()._M_const_cast(),
this);
542 else if (__first.
base() == _Base::begin()
543 || __last.
base() == _Base::end())
546 for (_Base_const_iterator __position = __first.
base();
547 __position != __last.
base(); ++__position)
553 return iterator(_Base::erase(__first.
base(), __last.
base()),
559 __throw_exception_again;
564 _Base_iterator __res = _Base::erase(__first.
base(),
567 return iterator(__res,
this);
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...
A standard container using fixed-size memory allocation and constant-time manipulation of elements at...
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
void _M_revalidate_singular()
_Iterator & base() noexcept
Return the underlying iterator.
#define __glibcxx_check_erase(_Position)
void _M_invalidate_if(_Predicate __pred)
#define __glibcxx_check_erase_range(_First, _Last)
Class std::deque with safety/checking/debug instrumentation.
void _M_detach_singular()
ISO C++ entities toplevel namespace is std.
void _M_invalidate_all() const
#define __glibcxx_check_insert(_Position)
#define __glibcxx_check_insert_range(_Position, _First, _Last)
Safe class dealing with some allocator dependent operations.