29 #ifndef _GLIBCXX_DEBUG_DEQUE
30 #define _GLIBCXX_DEBUG_DEQUE 1
32 #ifdef _GLIBCXX_SYSHDR
33 #pragma GCC system_header
37 namespace std _GLIBCXX_VISIBILITY(default) {
namespace __debug {
38 template<
typename _Tp,
typename _Allocator>
class deque;
46 namespace std _GLIBCXX_VISIBILITY(default)
51 template<
typename _Tp,
typename _Allocator = std::allocator<_Tp> >
54 deque<_Tp, _Allocator>, _Allocator,
55 __gnu_debug::_Safe_sequence>,
56 public _GLIBCXX_STD_C::deque<_Tp, _Allocator>
58 typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator>
_Base;
66 template<
typename _ItT,
typename _SeqT,
typename _CatT>
67 friend class ::__gnu_debug::_Safe_iterator;
74 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
80 typedef typename _Base::reference reference;
81 typedef typename _Base::const_reference const_reference;
88 typedef typename _Base::size_type size_type;
89 typedef typename _Base::difference_type difference_type;
91 typedef _Tp value_type;
92 typedef _Allocator allocator_type;
93 typedef typename _Base::pointer pointer;
94 typedef typename _Base::const_pointer const_pointer;
100 #if __cplusplus < 201103L
113 deque(
const deque& __d,
const __type_identity_t<_Allocator>& __a)
114 :
_Base(__d, __a) { }
116 deque(
deque&& __d,
const __type_identity_t<_Allocator>& __a)
120 const allocator_type& __a = allocator_type())
121 :
_Base(__l, __a) { }
127 deque(
const _Allocator& __a)
130 #if __cplusplus >= 201103L
132 deque(size_type __n,
const _Allocator& __a = _Allocator())
133 :
_Base(__n, __a) { }
135 deque(size_type __n,
const __type_identity_t<_Tp>& __value,
136 const _Allocator& __a = _Allocator())
137 :
_Base(__n, __value, __a) { }
140 deque(size_type __n,
const _Tp& __value = _Tp(),
141 const _Allocator& __a = _Allocator())
142 :
_Base(__n, __value, __a) { }
145 #if __cplusplus >= 201103L
146 template<
class _InputIterator,
147 typename = std::_RequireInputIter<_InputIterator>>
149 template<
class _InputIterator>
151 deque(_InputIterator __first, _InputIterator __last,
152 const _Allocator& __a = _Allocator())
154 __glibcxx_check_valid_constructor_range(__first, __last)),
158 #if __glibcxx_containers_ranges
159 template<__detail::__container_compatible_range<_Tp> _Rg>
160 deque(from_range_t, _Rg&& __rg,
const _Allocator& __a = _Allocator())
161 :
_Base(from_range, std::forward<_Rg>(__rg), __a)
166 :
_Base(__x._M_ref) { }
168 #if __cplusplus >= 201103L
170 operator=(
const deque&) =
default;
173 operator=(
deque&&) =
default;
178 _Base::operator=(__l);
184 #if __cplusplus >= 201103L
185 template<
class _InputIterator,
186 typename = std::_RequireInputIter<_InputIterator>>
188 template<
class _InputIterator>
191 assign(_InputIterator __first, _InputIterator __last)
194 __glibcxx_check_valid_range2(__first, __last, __dist);
195 if (__dist.
second >= __gnu_debug::__dp_sign)
196 _Base::assign(__gnu_debug::__unsafe(__first),
197 __gnu_debug::__unsafe(__last));
199 _Base::assign(__first, __last);
205 assign(size_type __n,
const _Tp& __t)
207 _Base::assign(__n, __t);
211 #if __cplusplus >= 201103L
220 #if __glibcxx_containers_ranges
221 template<std::__detail::__container_compatible_range<_Tp> _Rg>
223 assign_range(_Rg&& __rg)
225 _Base::assign_range(std::forward<_Rg>(__rg));
230 using _Base::get_allocator;
235 begin() _GLIBCXX_NOEXCEPT
236 {
return iterator(_Base::begin(),
this); }
240 begin()
const _GLIBCXX_NOEXCEPT
245 end() _GLIBCXX_NOEXCEPT
246 {
return iterator(_Base::end(),
this); }
250 end()
const _GLIBCXX_NOEXCEPT
255 rbegin() _GLIBCXX_NOEXCEPT
260 rbegin()
const _GLIBCXX_NOEXCEPT
265 rend() _GLIBCXX_NOEXCEPT
270 rend()
const _GLIBCXX_NOEXCEPT
273 #if __cplusplus >= 201103L
276 cbegin()
const noexcept
281 cend()
const noexcept
286 crbegin()
const noexcept
291 crend()
const noexcept
297 _M_invalidate_after_nth(difference_type __n)
306 using _Base::max_size;
308 #if __cplusplus >= 201103L
310 resize(size_type __sz)
312 bool __invalidate_all = __sz > this->
size();
313 if (__sz < this->
size())
314 this->_M_invalidate_after_nth(__sz);
318 if (__invalidate_all)
323 resize(size_type __sz,
const _Tp& __c)
325 bool __invalidate_all = __sz > this->
size();
326 if (__sz < this->
size())
327 this->_M_invalidate_after_nth(__sz);
329 _Base::resize(__sz, __c);
331 if (__invalidate_all)
336 resize(size_type __sz, _Tp __c = _Tp())
338 bool __invalidate_all = __sz > this->
size();
339 if (__sz < this->
size())
340 this->_M_invalidate_after_nth(__sz);
342 _Base::resize(__sz, __c);
344 if (__invalidate_all)
349 #if __cplusplus >= 201103L
351 shrink_to_fit() noexcept
353 if (_Base::_M_shrink_to_fit())
363 operator[](size_type __n) _GLIBCXX_NOEXCEPT
365 __glibcxx_check_subscript(__n);
366 return _Base::operator[](__n);
371 operator[](size_type __n)
const _GLIBCXX_NOEXCEPT
373 __glibcxx_check_subscript(__n);
374 return _Base::operator[](__n);
381 front() _GLIBCXX_NOEXCEPT
383 __glibcxx_check_nonempty();
384 return _Base::front();
389 front()
const _GLIBCXX_NOEXCEPT
391 __glibcxx_check_nonempty();
392 return _Base::front();
397 back() _GLIBCXX_NOEXCEPT
399 __glibcxx_check_nonempty();
400 return _Base::back();
405 back()
const _GLIBCXX_NOEXCEPT
407 __glibcxx_check_nonempty();
408 return _Base::back();
413 push_front(
const _Tp& __x)
415 _Base::push_front(__x);
420 push_back(
const _Tp& __x)
422 _Base::push_back(__x);
426 #if __cplusplus >= 201103L
428 push_front(_Tp&& __x)
435 template<
typename... _Args>
436 #if __cplusplus > 201402L
441 emplace_front(_Args&&... __args)
443 _Base::emplace_front(std::forward<_Args>(__args)...);
445 #if __cplusplus > 201402L
450 template<
typename... _Args>
451 #if __cplusplus > 201402L
456 emplace_back(_Args&&... __args)
458 _Base::emplace_back(std::forward<_Args>(__args)...);
460 #if __cplusplus > 201402L
465 template<
typename... _Args>
471 std::forward<_Args>(__args)...);
473 return iterator(__res,
this);
478 #if __cplusplus >= 201103L
481 insert(
iterator __position,
const _Tp& __x)
487 return iterator(__res,
this);
490 #if __cplusplus >= 201103L
493 {
return emplace(__position,
std::move(__x)); }
501 return iterator(__res,
this);
505 #if __cplusplus >= 201103L
512 return iterator(__res,
this);
516 insert(
iterator __position, size_type __n,
const _Tp& __x)
519 _Base::insert(__position.
base(), __n, __x);
524 #if __cplusplus >= 201103L
525 template<
class _InputIterator,
526 typename = std::_RequireInputIter<_InputIterator>>
529 _InputIterator __first, _InputIterator __last)
534 if (__dist.
second >= __gnu_debug::__dp_sign)
535 __res = _Base::insert(__position.
base(),
536 __gnu_debug::__unsafe(__first),
537 __gnu_debug::__unsafe(__last));
539 __res = _Base::insert(__position.
base(), __first, __last);
542 return iterator(__res,
this);
545 template<
class _InputIterator>
548 _InputIterator __first, _InputIterator __last)
553 if (__dist.
second >= __gnu_debug::__dp_sign)
554 _Base::insert(__position.
base(),
555 __gnu_debug::__unsafe(__first),
556 __gnu_debug::__unsafe(__last));
558 _Base::insert(__position.
base(), __first, __last);
564 #if __glibcxx_containers_ranges
565 template<__detail::__container_compatible_range<_Tp> _Rg>
569 auto __res = _Base::insert_range(__pos.
base(), std::forward<_Rg>(__rg));
571 return iterator(__res,
this);
574 template<std::__detail::__container_compatible_range<_Tp> _Rg>
576 prepend_range(_Rg&& __rg)
578 _Base::prepend_range(std::forward<_Rg>(__rg));
582 template<std::__detail::__container_compatible_range<_Tp> _Rg>
584 append_range(_Rg&& __rg)
586 _Base::append_range(std::forward<_Rg>(__rg));
592 pop_front() _GLIBCXX_NOEXCEPT
594 __glibcxx_check_nonempty();
600 pop_back() _GLIBCXX_NOEXCEPT
602 __glibcxx_check_nonempty();
608 #if __cplusplus >= 201103L
615 #if __cplusplus >= 201103L
620 if (__victim == _Base::begin() || __victim == _Base::end() - 1)
623 return iterator(_Base::erase(__victim),
this);
629 return iterator(__res,
this);
634 #if __cplusplus >= 201103L
644 if (__first.base() == __last.base())
645 #if __cplusplus >= 201103L
646 return iterator(__first.base()._M_const_cast(),
this);
650 else if (__first.base() == _Base::begin()
651 || __last.base() == _Base::end())
653 const deque* __this =
this;
656 __position != __last.
base(); ++__position)
662 return iterator(_Base::erase(__first.base(), __last.base()),
668 __throw_exception_again;
676 return iterator(__res,
this);
682 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
689 clear() _GLIBCXX_NOEXCEPT
696 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
699 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
702 #if __cpp_deduction_guides >= 201606
703 template<
typename _InputIterator,
typename _ValT
706 typename = _RequireInputIter<_InputIterator>,
707 typename = _RequireAllocator<_Allocator>>
708 deque(_InputIterator, _InputIterator, _Allocator = _Allocator())
711 template<
typename _Tp,
typename _Allocator = allocator<_Tp>,
712 typename = _RequireAllocator<_Allocator>>
713 deque(
size_t, _Tp, _Allocator = _Allocator())
716 #if __glibcxx_containers_ranges
717 template<ranges::input_range _Rg,
719 deque(from_range_t, _Rg&&, _Alloc = _Alloc())
724 template<
typename _Tp,
typename _Alloc>
728 {
return __lhs._M_base() == __rhs._M_base(); }
730 #if __cpp_lib_three_way_comparison
731 template<
typename _Tp,
typename _Alloc>
732 constexpr __detail::__synth3way_t<_Tp>
734 {
return __x._M_base() <=> __y._M_base(); }
736 template<
typename _Tp,
typename _Alloc>
738 operator!=(
const deque<_Tp, _Alloc>& __lhs,
739 const deque<_Tp, _Alloc>& __rhs)
740 {
return __lhs._M_base() != __rhs._M_base(); }
742 template<
typename _Tp,
typename _Alloc>
744 operator<(
const deque<_Tp, _Alloc>& __lhs,
745 const deque<_Tp, _Alloc>& __rhs)
746 {
return __lhs._M_base() < __rhs._M_base(); }
748 template<
typename _Tp,
typename _Alloc>
751 const deque<_Tp, _Alloc>& __rhs)
752 {
return __lhs._M_base() <= __rhs._M_base(); }
754 template<
typename _Tp,
typename _Alloc>
757 const deque<_Tp, _Alloc>& __rhs)
758 {
return __lhs._M_base() >= __rhs._M_base(); }
760 template<
typename _Tp,
typename _Alloc>
762 operator>(
const deque<_Tp, _Alloc>& __lhs,
763 const deque<_Tp, _Alloc>& __rhs)
764 {
return __lhs._M_base() > __rhs._M_base(); }
767 template<
typename _Tp,
typename _Alloc>
769 swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
770 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
771 { __lhs.swap(__rhs); }
775 #ifdef __glibcxx_erase_if
776 _GLIBCXX_BEGIN_NAMESPACE_VERSION
777 template<
typename _Tp,
typename _Alloc,
typename _Predicate>
778 inline typename __debug::deque<_Tp, _Alloc>::size_type
779 erase_if(__debug::deque<_Tp, _Alloc>&
__cont, _Predicate __pred)
784 template<
typename _Tp,
typename _Alloc,
typename _Up = _Tp>
785 inline typename __debug::deque<_Tp, _Alloc>::size_type
786 erase(__debug::deque<_Tp, _Alloc>&
__cont,
const _Up& __value)
787 {
return std::erase_if(
__cont, __gnu_cxx::__ops::__equal_to(__value)); }
788 _GLIBCXX_END_NAMESPACE_VERSION
#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 bool operator<=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator<(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
ISO C++ entities toplevel namespace is std.
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].
constexpr _Iterator & base() noexcept
Return the underlying iterator.
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.
Base class for constructing a safe sequence type that tracks iterators that reference it.
constexpr void _M_invalidate_if(_Predicate __pred) const
constexpr void _M_invalidate_all() const
void _M_detach_singular() const
void _M_revalidate_singular() const
Safe class dealing with some allocator dependent operations.
Class std::deque with safety/checking/debug instrumentation.