29 #ifndef _GLIBCXX_DEBUG_DEQUE
30 #define _GLIBCXX_DEBUG_DEQUE 1
32 #pragma GCC system_header
35 namespace std _GLIBCXX_VISIBILITY(default) {
namespace __debug {
36 template<
typename _Tp,
typename _Allocator>
class deque;
44 namespace std _GLIBCXX_VISIBILITY(default)
49 template<
typename _Tp,
typename _Allocator = std::allocator<_Tp> >
52 deque<_Tp, _Allocator>, _Allocator,
53 __gnu_debug::_Safe_sequence>,
54 public _GLIBCXX_STD_C::deque<_Tp, _Allocator>
56 typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator>
_Base;
64 template<
typename _ItT,
typename _SeqT,
typename _CatT>
65 friend class ::__gnu_debug::_Safe_iterator;
68 typedef typename _Base::reference reference;
69 typedef typename _Base::const_reference const_reference;
76 typedef typename _Base::size_type size_type;
77 typedef typename _Base::difference_type difference_type;
79 typedef _Tp value_type;
80 typedef _Allocator allocator_type;
81 typedef typename _Base::pointer pointer;
82 typedef typename _Base::const_pointer const_pointer;
88 #if __cplusplus < 201103L
101 deque(
const deque& __d,
const _Allocator& __a)
102 :
_Base(__d, __a) { }
108 const allocator_type& __a = allocator_type())
109 :
_Base(__l, __a) { }
115 deque(
const _Allocator& __a)
118 #if __cplusplus >= 201103L
120 deque(size_type __n,
const _Allocator& __a = _Allocator())
121 :
_Base(__n, __a) { }
123 deque(size_type __n,
const _Tp& __value,
124 const _Allocator& __a = _Allocator())
125 :
_Base(__n, __value, __a) { }
128 deque(size_type __n,
const _Tp& __value = _Tp(),
129 const _Allocator& __a = _Allocator())
130 :
_Base(__n, __value, __a) { }
133 #if __cplusplus >= 201103L
134 template<
class _InputIterator,
135 typename = std::_RequireInputIter<_InputIterator>>
137 template<
class _InputIterator>
139 deque(_InputIterator __first, _InputIterator __last,
140 const _Allocator& __a = _Allocator())
142 __glibcxx_check_valid_constructor_range(__first, __last)),
149 #if __cplusplus < 201103L
151 operator=(
const deque& __x)
153 this->_M_safe() = __x;
159 operator=(
const deque&) =
default;
162 operator=(
deque&&) =
default;
173 #if __cplusplus >= 201103L
174 template<
class _InputIterator,
175 typename = std::_RequireInputIter<_InputIterator>>
177 template<
class _InputIterator>
180 assign(_InputIterator __first, _InputIterator __last)
183 __glibcxx_check_valid_range2(__first, __last, __dist);
184 if (__dist.
second >= __gnu_debug::__dp_sign)
185 _Base::assign(__gnu_debug::__unsafe(__first),
186 __gnu_debug::__unsafe(__last));
188 _Base::assign(__first, __last);
194 assign(size_type __n,
const _Tp& __t)
196 _Base::assign(__n, __t);
200 #if __cplusplus >= 201103L
209 using _Base::get_allocator;
213 begin() _GLIBCXX_NOEXCEPT
214 {
return iterator(_Base::begin(),
this); }
217 begin()
const _GLIBCXX_NOEXCEPT
221 end() _GLIBCXX_NOEXCEPT
222 {
return iterator(_Base::end(),
this); }
225 end()
const _GLIBCXX_NOEXCEPT
229 rbegin() _GLIBCXX_NOEXCEPT
233 rbegin()
const _GLIBCXX_NOEXCEPT
237 rend() _GLIBCXX_NOEXCEPT
241 rend()
const _GLIBCXX_NOEXCEPT
244 #if __cplusplus >= 201103L
246 cbegin()
const noexcept
250 cend()
const noexcept
254 crbegin()
const noexcept
258 crend()
const noexcept
264 _M_invalidate_after_nth(difference_type __n)
273 using _Base::max_size;
275 #if __cplusplus >= 201103L
277 resize(size_type __sz)
279 bool __invalidate_all = __sz > this->size();
280 if (__sz < this->size())
281 this->_M_invalidate_after_nth(__sz);
285 if (__invalidate_all)
290 resize(size_type __sz,
const _Tp& __c)
292 bool __invalidate_all = __sz > this->size();
293 if (__sz < this->size())
294 this->_M_invalidate_after_nth(__sz);
296 _Base::resize(__sz, __c);
298 if (__invalidate_all)
303 resize(size_type __sz, _Tp __c = _Tp())
305 bool __invalidate_all = __sz > this->size();
306 if (__sz < this->size())
307 this->_M_invalidate_after_nth(__sz);
309 _Base::resize(__sz, __c);
311 if (__invalidate_all)
316 #if __cplusplus >= 201103L
318 shrink_to_fit() noexcept
320 if (_Base::_M_shrink_to_fit())
329 operator[](size_type __n) _GLIBCXX_NOEXCEPT
331 __glibcxx_check_subscript(__n);
332 return _M_base()[__n];
336 operator[](size_type __n)
const _GLIBCXX_NOEXCEPT
338 __glibcxx_check_subscript(__n);
339 return _M_base()[__n];
345 front() _GLIBCXX_NOEXCEPT
347 __glibcxx_check_nonempty();
348 return _Base::front();
352 front()
const _GLIBCXX_NOEXCEPT
354 __glibcxx_check_nonempty();
355 return _Base::front();
359 back() _GLIBCXX_NOEXCEPT
361 __glibcxx_check_nonempty();
362 return _Base::back();
366 back()
const _GLIBCXX_NOEXCEPT
368 __glibcxx_check_nonempty();
369 return _Base::back();
374 push_front(
const _Tp& __x)
376 _Base::push_front(__x);
381 push_back(
const _Tp& __x)
383 _Base::push_back(__x);
387 #if __cplusplus >= 201103L
389 push_front(_Tp&& __x)
396 template<
typename... _Args>
397 #if __cplusplus > 201402L
402 emplace_front(_Args&&... __args)
404 _Base::emplace_front(std::forward<_Args>(__args)...);
406 #if __cplusplus > 201402L
411 template<
typename... _Args>
412 #if __cplusplus > 201402L
417 emplace_back(_Args&&... __args)
419 _Base::emplace_back(std::forward<_Args>(__args)...);
421 #if __cplusplus > 201402L
426 template<
typename... _Args>
432 std::forward<_Args>(__args)...);
434 return iterator(__res,
this);
439 #if __cplusplus >= 201103L
442 insert(
iterator __position,
const _Tp& __x)
448 return iterator(__res,
this);
451 #if __cplusplus >= 201103L
454 {
return emplace(__position,
std::move(__x)); }
462 return iterator(__res,
this);
466 #if __cplusplus >= 201103L
473 return iterator(__res,
this);
477 insert(
iterator __position, size_type __n,
const _Tp& __x)
480 _Base::insert(__position.
base(), __n, __x);
485 #if __cplusplus >= 201103L
486 template<
class _InputIterator,
487 typename = std::_RequireInputIter<_InputIterator>>
490 _InputIterator __first, _InputIterator __last)
495 if (__dist.
second >= __gnu_debug::__dp_sign)
496 __res = _Base::insert(__position.
base(),
497 __gnu_debug::__unsafe(__first),
498 __gnu_debug::__unsafe(__last));
500 __res = _Base::insert(__position.
base(), __first, __last);
503 return iterator(__res,
this);
506 template<
class _InputIterator>
509 _InputIterator __first, _InputIterator __last)
514 if (__dist.
second >= __gnu_debug::__dp_sign)
515 _Base::insert(__position.
base(),
516 __gnu_debug::__unsafe(__first),
517 __gnu_debug::__unsafe(__last));
519 _Base::insert(__position.
base(), __first, __last);
526 pop_front() _GLIBCXX_NOEXCEPT
528 __glibcxx_check_nonempty();
534 pop_back() _GLIBCXX_NOEXCEPT
536 __glibcxx_check_nonempty();
542 #if __cplusplus >= 201103L
549 #if __cplusplus >= 201103L
554 if (__victim == _Base::begin() || __victim == _Base::end() - 1)
557 return iterator(_Base::erase(__victim),
this);
563 return iterator(__res,
this);
568 #if __cplusplus >= 201103L
578 if (__first.base() == __last.base())
579 #if __cplusplus >= 201103L
580 return iterator(__first.base()._M_const_cast(),
this);
584 else if (__first.base() == _Base::begin()
585 || __last.base() == _Base::end())
588 for (_Base_const_iterator __position = __first.
base();
589 __position != __last.
base(); ++__position)
595 return iterator(_Base::erase(__first.base(), __last.base()),
601 __throw_exception_again;
609 return iterator(__res,
this);
615 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
622 clear() _GLIBCXX_NOEXCEPT
629 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
632 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
635 #if __cpp_deduction_guides >= 201606
636 template<
typename _InputIterator,
typename _ValT
639 typename = _RequireInputIter<_InputIterator>,
640 typename = _RequireAllocator<_Allocator>>
641 deque(_InputIterator, _InputIterator, _Allocator = _Allocator())
645 template<
typename _Tp,
typename _Alloc>
649 {
return __lhs._M_base() == __rhs._M_base(); }
651 #if __cpp_lib_three_way_comparison
652 template<
typename _Tp,
typename _Alloc>
653 constexpr __detail::__synth3way_t<_Tp>
655 {
return __x._M_base() <=> __y._M_base(); }
657 template<
typename _Tp,
typename _Alloc>
659 operator!=(
const deque<_Tp, _Alloc>& __lhs,
660 const deque<_Tp, _Alloc>& __rhs)
661 {
return __lhs._M_base() != __rhs._M_base(); }
663 template<
typename _Tp,
typename _Alloc>
665 operator<(
const deque<_Tp, _Alloc>& __lhs,
666 const deque<_Tp, _Alloc>& __rhs)
667 {
return __lhs._M_base() < __rhs._M_base(); }
669 template<
typename _Tp,
typename _Alloc>
671 operator<=(
const deque<_Tp, _Alloc>& __lhs,
672 const deque<_Tp, _Alloc>& __rhs)
673 {
return __lhs._M_base() <= __rhs._M_base(); }
675 template<
typename _Tp,
typename _Alloc>
677 operator>=(
const deque<_Tp, _Alloc>& __lhs,
678 const deque<_Tp, _Alloc>& __rhs)
679 {
return __lhs._M_base() >= __rhs._M_base(); }
681 template<
typename _Tp,
typename _Alloc>
683 operator>(
const deque<_Tp, _Alloc>& __lhs,
684 const deque<_Tp, _Alloc>& __rhs)
685 {
return __lhs._M_base() > __rhs._M_base(); }
688 template<
typename _Tp,
typename _Alloc>
690 swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
691 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
692 { __lhs.swap(__rhs); }
#define __glibcxx_check_insert(_Position)
#define __glibcxx_check_erase_range(_First, _Last)
#define __glibcxx_check_erase(_Position)
#define __glibcxx_check_insert_range(_Position, _First, _Last, _Dist)
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
ISO C++ entities toplevel namespace is std.
constexpr _Iterator __base(_Iterator __it)
The standard allocator, as per [20.4].
Traits class for iterators.
A standard container using fixed-size memory allocation and constant-time manipulation of elements at...
Struct holding two objects of arbitrary type.
_T2 second
The second member.
_Iterator & base() noexcept
Return the underlying iterator.
Base class for constructing a safe sequence type that tracks iterators that reference it.
void _M_invalidate_if(_Predicate __pred)
void _M_invalidate_all() const
void _M_revalidate_singular()
void _M_detach_singular()
Safe class dealing with some allocator dependent operations.
Class std::deque with safety/checking/debug instrumentation.