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
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())
131 :
_Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
133 __gnu_debug::__base(__last), __a)
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;
158 this->_M_invalidate_all();
163 #if __cplusplus >= 201103L
164 template<
class _InputIterator,
165 typename = std::_RequireInputIter<_InputIterator>>
167 template<
class _InputIterator>
170 assign(_InputIterator __first, _InputIterator __last)
173 __glibcxx_check_valid_range2(__first, __last, __dist);
174 if (__dist.
second >= __gnu_debug::__dp_sign)
175 _Base::assign(__gnu_debug::__unsafe(__first),
176 __gnu_debug::__unsafe(__last));
178 _Base::assign(__first, __last);
180 this->_M_invalidate_all();
184 assign(size_type __n,
const _Tp& __t)
186 _Base::assign(__n, __t);
187 this->_M_invalidate_all();
190 #if __cplusplus >= 201103L
195 this->_M_invalidate_all();
199 using _Base::get_allocator;
203 begin() _GLIBCXX_NOEXCEPT
204 {
return iterator(_Base::begin(),
this); }
207 begin()
const _GLIBCXX_NOEXCEPT
211 end() _GLIBCXX_NOEXCEPT
212 {
return iterator(_Base::end(),
this); }
215 end()
const _GLIBCXX_NOEXCEPT
219 rbegin() _GLIBCXX_NOEXCEPT
223 rbegin()
const _GLIBCXX_NOEXCEPT
227 rend() _GLIBCXX_NOEXCEPT
231 rend()
const _GLIBCXX_NOEXCEPT
234 #if __cplusplus >= 201103L
236 cbegin()
const noexcept
240 cend()
const noexcept
244 crbegin()
const noexcept
248 crend()
const noexcept
254 _M_invalidate_after_nth(difference_type __n)
263 using _Base::max_size;
265 #if __cplusplus >= 201103L
267 resize(size_type __sz)
269 bool __invalidate_all = __sz > this->size();
270 if (__sz < this->size())
271 this->_M_invalidate_after_nth(__sz);
275 if (__invalidate_all)
276 this->_M_invalidate_all();
280 resize(size_type __sz,
const _Tp& __c)
282 bool __invalidate_all = __sz > this->size();
283 if (__sz < this->size())
284 this->_M_invalidate_after_nth(__sz);
286 _Base::resize(__sz, __c);
288 if (__invalidate_all)
289 this->_M_invalidate_all();
293 resize(size_type __sz, _Tp __c = _Tp())
295 bool __invalidate_all = __sz > this->size();
296 if (__sz < this->size())
297 this->_M_invalidate_after_nth(__sz);
299 _Base::resize(__sz, __c);
301 if (__invalidate_all)
302 this->_M_invalidate_all();
306 #if __cplusplus >= 201103L
308 shrink_to_fit() noexcept
310 if (_Base::_M_shrink_to_fit())
311 this->_M_invalidate_all();
319 operator[](size_type __n) _GLIBCXX_NOEXCEPT
321 __glibcxx_check_subscript(__n);
322 return _M_base()[__n];
326 operator[](size_type __n)
const _GLIBCXX_NOEXCEPT
328 __glibcxx_check_subscript(__n);
329 return _M_base()[__n];
335 front() _GLIBCXX_NOEXCEPT
337 __glibcxx_check_nonempty();
338 return _Base::front();
342 front()
const _GLIBCXX_NOEXCEPT
344 __glibcxx_check_nonempty();
345 return _Base::front();
349 back() _GLIBCXX_NOEXCEPT
351 __glibcxx_check_nonempty();
352 return _Base::back();
356 back()
const _GLIBCXX_NOEXCEPT
358 __glibcxx_check_nonempty();
359 return _Base::back();
364 push_front(
const _Tp& __x)
366 _Base::push_front(__x);
367 this->_M_invalidate_all();
371 push_back(
const _Tp& __x)
373 _Base::push_back(__x);
374 this->_M_invalidate_all();
377 #if __cplusplus >= 201103L
379 push_front(_Tp&& __x)
380 { emplace_front(std::move(__x)); }
384 { emplace_back(std::move(__x)); }
386 template<
typename... _Args>
388 emplace_front(_Args&&... __args)
390 _Base::emplace_front(std::forward<_Args>(__args)...);
391 this->_M_invalidate_all();
394 template<
typename... _Args>
396 emplace_back(_Args&&... __args)
398 _Base::emplace_back(std::forward<_Args>(__args)...);
399 this->_M_invalidate_all();
402 template<
typename... _Args>
408 std::forward<_Args>(__args)...);
409 this->_M_invalidate_all();
415 #if __cplusplus >= 201103L
418 insert(
iterator __position,
const _Tp& __x)
423 this->_M_invalidate_all();
427 #if __cplusplus >= 201103L
430 {
return emplace(__position, std::move(__x)); }
437 this->_M_invalidate_all();
442 #if __cplusplus >= 201103L
448 this->_M_invalidate_all();
453 insert(
iterator __position, size_type __n,
const _Tp& __x)
456 _Base::insert(__position.
base(), __n, __x);
457 this->_M_invalidate_all();
461 #if __cplusplus >= 201103L
462 template<
class _InputIterator,
463 typename = std::_RequireInputIter<_InputIterator>>
466 _InputIterator __first, _InputIterator __last)
471 if (__dist.
second >= __gnu_debug::__dp_sign)
472 __res = _Base::insert(__position.
base(),
473 __gnu_debug::__unsafe(__first),
474 __gnu_debug::__unsafe(__last));
476 __res = _Base::insert(__position.
base(), __first, __last);
478 this->_M_invalidate_all();
482 template<
class _InputIterator>
485 _InputIterator __first, _InputIterator __last)
490 if (__dist.
second >= __gnu_debug::__dp_sign)
491 _Base::insert(__position.
base(),
492 __gnu_debug::__unsafe(__first),
493 __gnu_debug::__unsafe(__last));
495 _Base::insert(__position.
base(), __first, __last);
497 this->_M_invalidate_all();
502 pop_front() _GLIBCXX_NOEXCEPT
504 __glibcxx_check_nonempty();
510 pop_back() _GLIBCXX_NOEXCEPT
512 __glibcxx_check_nonempty();
518 #if __cplusplus >= 201103L
525 #if __cplusplus >= 201103L
530 if (__victim == _Base::begin() || __victim == _Base::end() - 1)
533 return iterator(_Base::erase(__victim),
this);
538 this->_M_invalidate_all();
544 #if __cplusplus >= 201103L
554 if (__first.
base() == __last.
base())
555 #
if __cplusplus >= 201103L
560 else if (__first.
base() == _Base::begin()
561 || __last.
base() == _Base::end())
565 __position != __last.
base(); ++__position)
577 __throw_exception_again;
584 this->_M_invalidate_all();
591 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().
swap(__x)) )
598 clear() _GLIBCXX_NOEXCEPT
601 this->_M_invalidate_all();
605 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
608 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
611 template<
typename _Tp,
typename _Alloc>
615 {
return __lhs._M_base() == __rhs._M_base(); }
617 template<
typename _Tp,
typename _Alloc>
621 {
return __lhs._M_base() != __rhs._M_base(); }
623 template<
typename _Tp,
typename _Alloc>
625 operator<(const deque<_Tp, _Alloc>& __lhs,
626 const deque<_Tp, _Alloc>& __rhs)
627 {
return __lhs._M_base() < __rhs._M_base(); }
629 template<
typename _Tp,
typename _Alloc>
631 operator<=(const deque<_Tp, _Alloc>& __lhs,
632 const deque<_Tp, _Alloc>& __rhs)
633 {
return __lhs._M_base() <= __rhs._M_base(); }
635 template<
typename _Tp,
typename _Alloc>
637 operator>=(
const deque<_Tp, _Alloc>& __lhs,
638 const deque<_Tp, _Alloc>& __rhs)
639 {
return __lhs._M_base() >= __rhs._M_base(); }
641 template<
typename _Tp,
typename _Alloc>
643 operator>(
const deque<_Tp, _Alloc>& __lhs,
644 const deque<_Tp, _Alloc>& __rhs)
645 {
return __lhs._M_base() > __rhs._M_base(); }
647 template<
typename _Tp,
typename _Alloc>
649 swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
650 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
651 { __lhs.swap(__rhs); }
void _M_revalidate_singular()
#define __glibcxx_check_erase(_Position)
#define __glibcxx_check_insert_range(_Position, _First, _Last, _Dist)
#define __glibcxx_check_insert(_Position)
_Iterator & base() noexcept
Return the underlying iterator.
A standard container using fixed-size memory allocation and constant-time manipulation of elements at...
Safe class dealing with some allocator dependent operations.
Class std::deque with safety/checking/debug instrumentation.
void _M_detach_singular()
void _M_invalidate_if(_Predicate __pred)
#define __glibcxx_check_erase_range(_First, _Last)
void swap(basic_filebuf< _CharT, _Traits > &__x, basic_filebuf< _CharT, _Traits > &__y)
Swap specialization for filebufs.
_T2 second
first is a copy of the first object
Struct holding two objects of arbitrary type.
Base class for constructing a safe sequence type that tracks iterators that reference it...