29 #ifndef _GLIBCXX_DEBUG_DEQUE
30 #define _GLIBCXX_DEBUG_DEQUE 1
32 #pragma GCC system_header
39 namespace std _GLIBCXX_VISIBILITY(default)
44 template<
typename _Tp,
typename _Allocator = std::allocator<_Tp> >
47 deque<_Tp, _Allocator>, _Allocator,
48 __gnu_debug::_Safe_sequence>,
49 public _GLIBCXX_STD_C::deque<_Tp, _Allocator>
51 typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator>
_Base;
60 typedef typename _Base::reference reference;
61 typedef typename _Base::const_reference const_reference;
68 typedef typename _Base::size_type size_type;
69 typedef typename _Base::difference_type difference_type;
71 typedef _Tp value_type;
72 typedef _Allocator allocator_type;
73 typedef typename _Base::pointer pointer;
74 typedef typename _Base::const_pointer const_pointer;
80 #if __cplusplus < 201103L
97 :
_Safe(std::move(__d)),
_Base(std::move(__d), __a) { }
100 const allocator_type& __a = allocator_type())
101 :
_Base(__l, __a) { }
107 deque(
const _Allocator& __a)
110 #if __cplusplus >= 201103L
112 deque(size_type __n,
const _Allocator& __a = _Allocator())
113 :
_Base(__n, __a) { }
115 deque(size_type __n,
const _Tp& __value,
116 const _Allocator& __a = _Allocator())
117 :
_Base(__n, __value, __a) { }
120 deque(size_type __n,
const _Tp& __value = _Tp(),
121 const _Allocator& __a = _Allocator())
122 :
_Base(__n, __value, __a) { }
125 #if __cplusplus >= 201103L
126 template<
class _InputIterator,
127 typename = std::_RequireInputIter<_InputIterator>>
129 template<
class _InputIterator>
131 deque(_InputIterator __first, _InputIterator __last,
132 const _Allocator& __a = _Allocator())
133 :
_Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
135 __gnu_debug::__base(__last), __a)
138 deque(
const _Base& __x)
141 #if __cplusplus < 201103L
143 operator=(
const deque& __x)
145 this->_M_safe() = __x;
151 operator=(
const deque&) =
default;
154 operator=(deque&&) =
default;
160 this->_M_invalidate_all();
165 #if __cplusplus >= 201103L
166 template<
class _InputIterator,
167 typename = std::_RequireInputIter<_InputIterator>>
169 template<
class _InputIterator>
172 assign(_InputIterator __first, _InputIterator __last)
175 __glibcxx_check_valid_range2(__first, __last, __dist);
176 if (__dist.
second >= __gnu_debug::__dp_sign)
177 _Base::assign(__gnu_debug::__unsafe(__first),
178 __gnu_debug::__unsafe(__last));
180 _Base::assign(__first, __last);
182 this->_M_invalidate_all();
186 assign(size_type __n,
const _Tp& __t)
188 _Base::assign(__n, __t);
189 this->_M_invalidate_all();
192 #if __cplusplus >= 201103L
197 this->_M_invalidate_all();
201 using _Base::get_allocator;
205 begin() _GLIBCXX_NOEXCEPT
206 {
return iterator(_Base::begin(),
this); }
209 begin()
const _GLIBCXX_NOEXCEPT
213 end() _GLIBCXX_NOEXCEPT
214 {
return iterator(_Base::end(),
this); }
217 end()
const _GLIBCXX_NOEXCEPT
221 rbegin() _GLIBCXX_NOEXCEPT
225 rbegin()
const _GLIBCXX_NOEXCEPT
229 rend() _GLIBCXX_NOEXCEPT
233 rend()
const _GLIBCXX_NOEXCEPT
236 #if __cplusplus >= 201103L
238 cbegin()
const noexcept
242 cend()
const noexcept
246 crbegin()
const noexcept
250 crend()
const noexcept
256 _M_invalidate_after_nth(difference_type __n)
265 using _Base::max_size;
267 #if __cplusplus >= 201103L
269 resize(size_type __sz)
271 bool __invalidate_all = __sz > this->size();
272 if (__sz < this->size())
273 this->_M_invalidate_after_nth(__sz);
277 if (__invalidate_all)
278 this->_M_invalidate_all();
282 resize(size_type __sz,
const _Tp& __c)
284 bool __invalidate_all = __sz > this->size();
285 if (__sz < this->size())
286 this->_M_invalidate_after_nth(__sz);
288 _Base::resize(__sz, __c);
290 if (__invalidate_all)
291 this->_M_invalidate_all();
295 resize(size_type __sz, _Tp __c = _Tp())
297 bool __invalidate_all = __sz > this->size();
298 if (__sz < this->size())
299 this->_M_invalidate_after_nth(__sz);
301 _Base::resize(__sz, __c);
303 if (__invalidate_all)
304 this->_M_invalidate_all();
308 #if __cplusplus >= 201103L
310 shrink_to_fit() noexcept
312 if (_Base::_M_shrink_to_fit())
313 this->_M_invalidate_all();
321 operator[](size_type __n) _GLIBCXX_NOEXCEPT
323 __glibcxx_check_subscript(__n);
324 return _M_base()[__n];
328 operator[](size_type __n)
const _GLIBCXX_NOEXCEPT
330 __glibcxx_check_subscript(__n);
331 return _M_base()[__n];
337 front() _GLIBCXX_NOEXCEPT
339 __glibcxx_check_nonempty();
340 return _Base::front();
344 front()
const _GLIBCXX_NOEXCEPT
346 __glibcxx_check_nonempty();
347 return _Base::front();
351 back() _GLIBCXX_NOEXCEPT
353 __glibcxx_check_nonempty();
354 return _Base::back();
358 back()
const _GLIBCXX_NOEXCEPT
360 __glibcxx_check_nonempty();
361 return _Base::back();
366 push_front(
const _Tp& __x)
368 _Base::push_front(__x);
369 this->_M_invalidate_all();
373 push_back(
const _Tp& __x)
375 _Base::push_back(__x);
376 this->_M_invalidate_all();
379 #if __cplusplus >= 201103L
381 push_front(_Tp&& __x)
382 { emplace_front(std::move(__x)); }
386 { emplace_back(std::move(__x)); }
388 template<
typename... _Args>
389 #if __cplusplus > 201402L
394 emplace_front(_Args&&... __args)
396 _Base::emplace_front(std::forward<_Args>(__args)...);
397 this->_M_invalidate_all();
398 #if __cplusplus > 201402L
403 template<
typename... _Args>
404 #if __cplusplus > 201402L
409 emplace_back(_Args&&... __args)
411 _Base::emplace_back(std::forward<_Args>(__args)...);
412 this->_M_invalidate_all();
413 #if __cplusplus > 201402L
418 template<
typename... _Args>
424 std::forward<_Args>(__args)...);
425 this->_M_invalidate_all();
431 #if __cplusplus >= 201103L
434 insert(
iterator __position,
const _Tp& __x)
439 this->_M_invalidate_all();
443 #if __cplusplus >= 201103L
446 {
return emplace(__position, std::move(__x)); }
453 this->_M_invalidate_all();
458 #if __cplusplus >= 201103L
464 this->_M_invalidate_all();
469 insert(
iterator __position, size_type __n,
const _Tp& __x)
472 _Base::insert(__position.
base(), __n, __x);
473 this->_M_invalidate_all();
477 #if __cplusplus >= 201103L
478 template<
class _InputIterator,
479 typename = std::_RequireInputIter<_InputIterator>>
482 _InputIterator __first, _InputIterator __last)
487 if (__dist.
second >= __gnu_debug::__dp_sign)
488 __res = _Base::insert(__position.
base(),
489 __gnu_debug::__unsafe(__first),
490 __gnu_debug::__unsafe(__last));
492 __res = _Base::insert(__position.
base(), __first, __last);
494 this->_M_invalidate_all();
498 template<
class _InputIterator>
501 _InputIterator __first, _InputIterator __last)
506 if (__dist.
second >= __gnu_debug::__dp_sign)
507 _Base::insert(__position.
base(),
508 __gnu_debug::__unsafe(__first),
509 __gnu_debug::__unsafe(__last));
511 _Base::insert(__position.
base(), __first, __last);
513 this->_M_invalidate_all();
518 pop_front() _GLIBCXX_NOEXCEPT
520 __glibcxx_check_nonempty();
526 pop_back() _GLIBCXX_NOEXCEPT
528 __glibcxx_check_nonempty();
534 #if __cplusplus >= 201103L
541 #if __cplusplus >= 201103L
546 if (__victim == _Base::begin() || __victim == _Base::end() - 1)
549 return iterator(_Base::erase(__victim),
this);
554 this->_M_invalidate_all();
560 #if __cplusplus >= 201103L
570 if (__first.
base() == __last.
base())
571 #
if __cplusplus >= 201103L
576 else if (__first.
base() == _Base::begin()
577 || __last.
base() == _Base::end())
581 __position != __last.
base(); ++__position)
593 __throw_exception_again;
600 this->_M_invalidate_all();
607 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
614 clear() _GLIBCXX_NOEXCEPT
617 this->_M_invalidate_all();
621 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
624 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
627 #if __cpp_deduction_guides >= 201606
628 template<
typename _InputIterator,
typename _ValT
629 =
typename iterator_traits<_InputIterator>::value_type,
631 typename = _RequireInputIter<_InputIterator>,
632 typename = _RequireAllocator<_Allocator>>
633 deque(_InputIterator, _InputIterator, _Allocator = _Allocator())
637 template<
typename _Tp,
typename _Alloc>
641 {
return __lhs._M_base() == __rhs._M_base(); }
643 template<
typename _Tp,
typename _Alloc>
647 {
return __lhs._M_base() != __rhs._M_base(); }
649 template<
typename _Tp,
typename _Alloc>
651 operator<(const deque<_Tp, _Alloc>& __lhs,
652 const deque<_Tp, _Alloc>& __rhs)
653 {
return __lhs._M_base() < __rhs._M_base(); }
655 template<
typename _Tp,
typename _Alloc>
657 operator<=(const deque<_Tp, _Alloc>& __lhs,
658 const deque<_Tp, _Alloc>& __rhs)
659 {
return __lhs._M_base() <= __rhs._M_base(); }
661 template<
typename _Tp,
typename _Alloc>
663 operator>=(
const deque<_Tp, _Alloc>& __lhs,
664 const deque<_Tp, _Alloc>& __rhs)
665 {
return __lhs._M_base() >= __rhs._M_base(); }
667 template<
typename _Tp,
typename _Alloc>
669 operator>(
const deque<_Tp, _Alloc>& __lhs,
670 const deque<_Tp, _Alloc>& __rhs)
671 {
return __lhs._M_base() > __rhs._M_base(); }
673 template<
typename _Tp,
typename _Alloc>
675 swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
676 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
677 { __lhs.swap(__rhs); }
void _M_invalidate_if(_Predicate __pred)
Safe class dealing with some allocator dependent operations.
Class std::deque with safety/checking/debug instrumentation.
_Iterator & base() noexcept
Return the underlying iterator.
#define __glibcxx_check_insert_range(_Position, _First, _Last, _Dist)
enable_if< ::__array_traits< _Tp, _Nm >::_Is_swappable::value >::type noexcept(noexcept(__one.swap(__two)))
swap
A standard container using fixed-size memory allocation and constant-time manipulation of elements at...
Struct holding two objects of arbitrary type.
The standard allocator, as per [20.4].
Base class for constructing a safe sequence type that tracks iterators that reference it...
_T2 second
first is a copy of the first object
void _M_detach_singular()
#define __glibcxx_check_erase_range(_First, _Last)
#define __glibcxx_check_insert(_Position)
#define __glibcxx_check_erase(_Position)
void _M_revalidate_singular()