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;
72 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
78 typedef typename _Base::reference reference;
79 typedef typename _Base::const_reference const_reference;
86 typedef typename _Base::size_type size_type;
87 typedef typename _Base::difference_type difference_type;
89 typedef _Tp value_type;
90 typedef _Allocator allocator_type;
91 typedef typename _Base::pointer pointer;
92 typedef typename _Base::const_pointer const_pointer;
98 #if __cplusplus < 201103L
111 deque(
const deque& __d,
const _Allocator& __a)
112 :
_Base(__d, __a) { }
118 const allocator_type& __a = allocator_type())
119 :
_Base(__l, __a) { }
125 deque(
const _Allocator& __a)
128 #if __cplusplus >= 201103L
130 deque(size_type __n,
const _Allocator& __a = _Allocator())
131 :
_Base(__n, __a) { }
133 deque(size_type __n,
const __type_identity_t<_Tp>& __value,
134 const _Allocator& __a = _Allocator())
135 :
_Base(__n, __value, __a) { }
138 deque(size_type __n,
const _Tp& __value = _Tp(),
139 const _Allocator& __a = _Allocator())
140 :
_Base(__n, __value, __a) { }
143 #if __cplusplus >= 201103L
144 template<
class _InputIterator,
145 typename = std::_RequireInputIter<_InputIterator>>
147 template<
class _InputIterator>
149 deque(_InputIterator __first, _InputIterator __last,
150 const _Allocator& __a = _Allocator())
152 __glibcxx_check_valid_constructor_range(__first, __last)),
157 :
_Base(__x._M_ref) { }
159 #if __cplusplus < 201103L
161 operator=(
const deque& __x)
163 this->_M_safe() = __x;
169 operator=(
const deque&) =
default;
172 operator=(
deque&&) =
default;
183 #if __cplusplus >= 201103L
184 template<
class _InputIterator,
185 typename = std::_RequireInputIter<_InputIterator>>
187 template<
class _InputIterator>
190 assign(_InputIterator __first, _InputIterator __last)
193 __glibcxx_check_valid_range2(__first, __last, __dist);
194 if (__dist.
second >= __gnu_debug::__dp_sign)
195 _Base::assign(__gnu_debug::__unsafe(__first),
196 __gnu_debug::__unsafe(__last));
198 _Base::assign(__first, __last);
204 assign(size_type __n,
const _Tp& __t)
206 _Base::assign(__n, __t);
210 #if __cplusplus >= 201103L
219 using _Base::get_allocator;
223 begin() _GLIBCXX_NOEXCEPT
224 {
return iterator(_Base::begin(),
this); }
227 begin()
const _GLIBCXX_NOEXCEPT
231 end() _GLIBCXX_NOEXCEPT
232 {
return iterator(_Base::end(),
this); }
235 end()
const _GLIBCXX_NOEXCEPT
239 rbegin() _GLIBCXX_NOEXCEPT
243 rbegin()
const _GLIBCXX_NOEXCEPT
247 rend() _GLIBCXX_NOEXCEPT
251 rend()
const _GLIBCXX_NOEXCEPT
254 #if __cplusplus >= 201103L
256 cbegin()
const noexcept
260 cend()
const noexcept
264 crbegin()
const noexcept
268 crend()
const noexcept
274 _M_invalidate_after_nth(difference_type __n)
283 using _Base::max_size;
285 #if __cplusplus >= 201103L
287 resize(size_type __sz)
289 bool __invalidate_all = __sz > this->
size();
290 if (__sz < this->
size())
291 this->_M_invalidate_after_nth(__sz);
295 if (__invalidate_all)
300 resize(size_type __sz,
const _Tp& __c)
302 bool __invalidate_all = __sz > this->
size();
303 if (__sz < this->
size())
304 this->_M_invalidate_after_nth(__sz);
306 _Base::resize(__sz, __c);
308 if (__invalidate_all)
313 resize(size_type __sz, _Tp __c = _Tp())
315 bool __invalidate_all = __sz > this->
size();
316 if (__sz < this->
size())
317 this->_M_invalidate_after_nth(__sz);
319 _Base::resize(__sz, __c);
321 if (__invalidate_all)
326 #if __cplusplus >= 201103L
328 shrink_to_fit() noexcept
330 if (_Base::_M_shrink_to_fit())
339 operator[](size_type __n) _GLIBCXX_NOEXCEPT
341 __glibcxx_check_subscript(__n);
342 return _M_base()[__n];
346 operator[](size_type __n)
const _GLIBCXX_NOEXCEPT
348 __glibcxx_check_subscript(__n);
349 return _M_base()[__n];
355 front() _GLIBCXX_NOEXCEPT
357 __glibcxx_check_nonempty();
358 return _Base::front();
362 front()
const _GLIBCXX_NOEXCEPT
364 __glibcxx_check_nonempty();
365 return _Base::front();
369 back() _GLIBCXX_NOEXCEPT
371 __glibcxx_check_nonempty();
372 return _Base::back();
376 back()
const _GLIBCXX_NOEXCEPT
378 __glibcxx_check_nonempty();
379 return _Base::back();
384 push_front(
const _Tp& __x)
386 _Base::push_front(__x);
391 push_back(
const _Tp& __x)
393 _Base::push_back(__x);
397 #if __cplusplus >= 201103L
399 push_front(_Tp&& __x)
406 template<
typename... _Args>
407 #if __cplusplus > 201402L
412 emplace_front(_Args&&... __args)
414 _Base::emplace_front(std::forward<_Args>(__args)...);
416 #if __cplusplus > 201402L
421 template<
typename... _Args>
422 #if __cplusplus > 201402L
427 emplace_back(_Args&&... __args)
429 _Base::emplace_back(std::forward<_Args>(__args)...);
431 #if __cplusplus > 201402L
436 template<
typename... _Args>
442 std::forward<_Args>(__args)...);
444 return iterator(__res,
this);
449 #if __cplusplus >= 201103L
452 insert(
iterator __position,
const _Tp& __x)
458 return iterator(__res,
this);
461 #if __cplusplus >= 201103L
464 {
return emplace(__position,
std::move(__x)); }
472 return iterator(__res,
this);
476 #if __cplusplus >= 201103L
483 return iterator(__res,
this);
487 insert(
iterator __position, size_type __n,
const _Tp& __x)
490 _Base::insert(__position.
base(), __n, __x);
495 #if __cplusplus >= 201103L
496 template<
class _InputIterator,
497 typename = std::_RequireInputIter<_InputIterator>>
500 _InputIterator __first, _InputIterator __last)
505 if (__dist.
second >= __gnu_debug::__dp_sign)
506 __res = _Base::insert(__position.
base(),
507 __gnu_debug::__unsafe(__first),
508 __gnu_debug::__unsafe(__last));
510 __res = _Base::insert(__position.
base(), __first, __last);
513 return iterator(__res,
this);
516 template<
class _InputIterator>
519 _InputIterator __first, _InputIterator __last)
524 if (__dist.
second >= __gnu_debug::__dp_sign)
525 _Base::insert(__position.
base(),
526 __gnu_debug::__unsafe(__first),
527 __gnu_debug::__unsafe(__last));
529 _Base::insert(__position.
base(), __first, __last);
536 pop_front() _GLIBCXX_NOEXCEPT
538 __glibcxx_check_nonempty();
544 pop_back() _GLIBCXX_NOEXCEPT
546 __glibcxx_check_nonempty();
552 #if __cplusplus >= 201103L
559 #if __cplusplus >= 201103L
564 if (__victim == _Base::begin() || __victim == _Base::end() - 1)
567 return iterator(_Base::erase(__victim),
this);
573 return iterator(__res,
this);
578 #if __cplusplus >= 201103L
588 if (__first.base() == __last.base())
589 #if __cplusplus >= 201103L
590 return iterator(__first.base()._M_const_cast(),
this);
594 else if (__first.base() == _Base::begin()
595 || __last.base() == _Base::end())
598 for (_Base_const_iterator __position = __first.
base();
599 __position != __last.
base(); ++__position)
605 return iterator(_Base::erase(__first.base(), __last.base()),
611 __throw_exception_again;
619 return iterator(__res,
this);
625 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
632 clear() _GLIBCXX_NOEXCEPT
639 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
642 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
645 #if __cpp_deduction_guides >= 201606
646 template<
typename _InputIterator,
typename _ValT
649 typename = _RequireInputIter<_InputIterator>,
650 typename = _RequireAllocator<_Allocator>>
651 deque(_InputIterator, _InputIterator, _Allocator = _Allocator())
654 template<
typename _Tp,
typename _Allocator = allocator<_Tp>,
655 typename = _RequireAllocator<_Allocator>>
656 deque(
size_t, _Tp, _Allocator = _Allocator())
660 template<
typename _Tp,
typename _Alloc>
664 {
return __lhs._M_base() == __rhs._M_base(); }
666 #if __cpp_lib_three_way_comparison
667 template<
typename _Tp,
typename _Alloc>
668 constexpr __detail::__synth3way_t<_Tp>
670 {
return __x._M_base() <=> __y._M_base(); }
672 template<
typename _Tp,
typename _Alloc>
674 operator!=(
const deque<_Tp, _Alloc>& __lhs,
675 const deque<_Tp, _Alloc>& __rhs)
676 {
return __lhs._M_base() != __rhs._M_base(); }
678 template<
typename _Tp,
typename _Alloc>
680 operator<(
const deque<_Tp, _Alloc>& __lhs,
681 const deque<_Tp, _Alloc>& __rhs)
682 {
return __lhs._M_base() < __rhs._M_base(); }
684 template<
typename _Tp,
typename _Alloc>
686 operator<=(
const deque<_Tp, _Alloc>& __lhs,
687 const deque<_Tp, _Alloc>& __rhs)
688 {
return __lhs._M_base() <= __rhs._M_base(); }
690 template<
typename _Tp,
typename _Alloc>
692 operator>=(
const deque<_Tp, _Alloc>& __lhs,
693 const deque<_Tp, _Alloc>& __rhs)
694 {
return __lhs._M_base() >= __rhs._M_base(); }
696 template<
typename _Tp,
typename _Alloc>
698 operator>(
const deque<_Tp, _Alloc>& __lhs,
699 const deque<_Tp, _Alloc>& __rhs)
700 {
return __lhs._M_base() > __rhs._M_base(); }
703 template<
typename _Tp,
typename _Alloc>
705 swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
706 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
707 { __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.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
ISO C++ entities toplevel namespace is std.
constexpr auto empty(const _Container &__cont) noexcept(noexcept(__cont.empty())) -> decltype(__cont.empty())
Return whether a container is empty.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
constexpr _Iterator __base(_Iterator __it)
The standard allocator, as per C++03 [20.4.1].
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.