29 #ifndef _GLIBCXX_DEBUG_SAFE_LOCAL_ITERATOR_H 30 #define _GLIBCXX_DEBUG_SAFE_LOCAL_ITERATOR_H 1 51 template<
typename _Iterator,
typename _Sequence>
52 class _Safe_local_iterator
54 ,
public _Safe_local_iterator_base
56 typedef _Iterator _Iter_base;
58 typedef typename _Sequence::const_local_iterator _Const_local_iterator;
59 typedef typename _Sequence::size_type size_type;
65 return std::__are_same<_Const_local_iterator,
69 typedef std::iterator_traits<_Iterator> _Traits;
75 _Attach_single) noexcept
80 typedef _Iterator iterator_type;
81 typedef typename _Traits::iterator_category iterator_category;
82 typedef typename _Traits::value_type value_type;
83 typedef typename _Traits::difference_type difference_type;
84 typedef typename _Traits::reference reference;
85 typedef typename _Traits::pointer pointer;
99 : _Iter_base(__i), _Safe_base(__cont, _M_constant())
102 _M_message(__msg_init_singular)
103 ._M_iterator(*
this,
"this"));
110 : _Iter_base(__x.base())
114 _GLIBCXX_DEBUG_VERIFY(!__x._M_singular()
115 || __x.base() == _Iterator(),
116 _M_message(__msg_init_copy_singular)
117 ._M_iterator(*
this,
"this")
118 ._M_iterator(__x,
"other"));
129 _GLIBCXX_DEBUG_VERIFY(!__x._M_singular()
130 || __x.base() == _Iterator(),
131 _M_message(__msg_init_copy_singular)
132 ._M_iterator(*
this,
"this")
133 ._M_iterator(__x,
"other"));
134 auto __cont = __x._M_sequence;
136 std::swap(
base(), __x.base());
144 template<
typename _MutableIterator>
147 typename __gnu_cxx::__enable_if<std::__are_same<
149 typename _Sequence::local_iterator::iterator_type>::__value,
150 _Sequence>::__type>& __x)
151 : _Iter_base(__x.
base())
155 _GLIBCXX_DEBUG_VERIFY(!__x._M_singular()
156 || __x.base() == _Iterator(),
157 _M_message(__msg_init_const_singular)
158 ._M_iterator(*
this,
"this")
159 ._M_iterator(__x,
"other"));
171 _GLIBCXX_DEBUG_VERIFY(!__x._M_singular()
172 || __x.base() == _Iterator(),
173 _M_message(__msg_copy_singular)
174 ._M_iterator(*
this,
"this")
175 ._M_iterator(__x,
"other"));
200 _GLIBCXX_DEBUG_VERIFY(
this != &__x,
201 _M_message(__msg_self_move_assign)
202 ._M_iterator(*
this,
"this"));
203 _GLIBCXX_DEBUG_VERIFY(!__x._M_singular()
204 || __x.base() == _Iterator(),
205 _M_message(__msg_copy_singular)
206 ._M_iterator(*
this,
"this")
207 ._M_iterator(__x,
"other"));
223 __x.base() = _Iterator();
235 _M_message(__msg_bad_deref)
236 ._M_iterator(*
this,
"this"));
249 _M_message(__msg_bad_deref)
250 ._M_iterator(*
this,
"this"));
263 _M_message(__msg_bad_inc)
264 ._M_iterator(*
this,
"this"));
278 _M_message(__msg_bad_inc)
279 ._M_iterator(*
this,
"this"));
290 base() noexcept {
return *
this; }
293 base()
const noexcept {
return *
this; }
305 operator _Iterator()
const {
return *
this; }
333 __gnu_cxx::__conditional_type<std::__are_same<_Const_local_iterator,
337 _M_get_sequence()
const 342 {
return base() == _M_get_sequence()->_M_base().begin(
bucket()); }
346 {
return base() == _M_get_sequence()->_M_base().end(
bucket()); }
349 template<
typename _Other>
352 _Sequence>& __other)
const 353 {
return bucket() == __other.bucket(); }
356 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
361 _GLIBCXX_DEBUG_VERIFY(!__lhs._M_singular() && !__rhs._M_singular(),
362 _M_message(__msg_iter_compare_bad)
363 ._M_iterator(__lhs,
"lhs")
364 ._M_iterator(__rhs,
"rhs"));
365 _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
366 _M_message(__msg_compare_different)
367 ._M_iterator(__lhs,
"lhs")
368 ._M_iterator(__rhs,
"rhs"));
369 _GLIBCXX_DEBUG_VERIFY(__lhs._M_in_same_bucket(__rhs),
370 _M_message(__msg_local_iter_compare_bad)
371 ._M_iterator(__lhs,
"lhs")
372 ._M_iterator(__rhs,
"rhs"));
373 return __lhs.base() == __rhs.base();
376 template<
typename _Iterator,
typename _Sequence>
381 _GLIBCXX_DEBUG_VERIFY(!__lhs._M_singular() && !__rhs._M_singular(),
382 _M_message(__msg_iter_compare_bad)
383 ._M_iterator(__lhs,
"lhs")
384 ._M_iterator(__rhs,
"rhs"));
385 _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
386 _M_message(__msg_compare_different)
387 ._M_iterator(__lhs,
"lhs")
388 ._M_iterator(__rhs,
"rhs"));
389 _GLIBCXX_DEBUG_VERIFY(__lhs._M_in_same_bucket(__rhs),
390 _M_message(__msg_local_iter_compare_bad)
391 ._M_iterator(__lhs,
"lhs")
392 ._M_iterator(__rhs,
"rhs"));
393 return __lhs.base() == __rhs.base();
396 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
401 _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
402 _M_message(__msg_iter_compare_bad)
403 ._M_iterator(__lhs,
"lhs")
404 ._M_iterator(__rhs,
"rhs"));
405 _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
406 _M_message(__msg_compare_different)
407 ._M_iterator(__lhs,
"lhs")
408 ._M_iterator(__rhs,
"rhs"));
409 _GLIBCXX_DEBUG_VERIFY(__lhs._M_in_same_bucket(__rhs),
410 _M_message(__msg_local_iter_compare_bad)
411 ._M_iterator(__lhs,
"lhs")
412 ._M_iterator(__rhs,
"rhs"));
413 return __lhs.base() != __rhs.base();
416 template<
typename _Iterator,
typename _Sequence>
421 _GLIBCXX_DEBUG_VERIFY(!__lhs._M_singular() && !__rhs._M_singular(),
422 _M_message(__msg_iter_compare_bad)
423 ._M_iterator(__lhs,
"lhs")
424 ._M_iterator(__rhs,
"rhs"));
425 _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
426 _M_message(__msg_compare_different)
427 ._M_iterator(__lhs,
"lhs")
428 ._M_iterator(__rhs,
"rhs"));
429 _GLIBCXX_DEBUG_VERIFY(__lhs._M_in_same_bucket(__rhs),
430 _M_message(__msg_local_iter_compare_bad)
431 ._M_iterator(__lhs,
"lhs")
432 ._M_iterator(__rhs,
"rhs"));
433 return __lhs.base() != __rhs.base();
_Safe_local_iterator(const _Iterator &__i, const _Safe_sequence_base *__cont)
Safe iterator construction from an unsafe iterator and its sequence.
bool _M_is_end() const
Is this iterator equal to the sequence's end(bucket) iterator?
bool _M_in_same_bucket(const _Safe_local_iterator< _Other, _Sequence > &__other) const
Is this iterator part of the same bucket as the other one?
_Safe_local_iterator(_Safe_local_iterator &&__x) noexcept
Move construction.
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
void _M_attach(_Safe_sequence_base *__seq, bool __constant)
reference operator*() const
Iterator dereference.
_Safe_local_iterator() noexcept
_Safe_local_iterator & operator=(_Safe_local_iterator &&__x) noexcept
Move assignment.
_Safe_local_iterator & operator=(const _Safe_local_iterator &__x)
Copy assignment.
Base class that supports tracking of iterators that reference a sequence.
__gnu_cxx::__mutex & _M_get_mutex()
bool _M_incrementable() const
Is the iterator incrementable?
GNU debug classes for public use.
void _M_attach_single(_Safe_sequence_base *__seq)
void _M_attach_single(_Safe_sequence_base *__seq, bool __constant)
_Iterator & base() noexcept
Return the underlying iterator.
void _M_attach(_Safe_sequence_base *__seq)
_Safe_local_iterator operator++(int)
Iterator postincrement.
_Safe_local_iterator(const _Safe_local_iterator< _MutableIterator, typename __gnu_cxx::__enable_if< std::__are_same< _MutableIterator, typename _Sequence::local_iterator::iterator_type >::__value, _Sequence >::__type > &__x)
Converting constructor from a mutable iterator to a constant iterator.
_Safe_local_iterator(const _Safe_local_iterator &__x) noexcept
Copy construction.
bool _M_is_begin() const
Is this iterator equal to the sequence's begin(bucket) iterator?
_Safe_local_iterator_base()
bool _M_dereferenceable() const
Is the iterator dereferenceable?
size_type bucket() const
Return the bucket.
_Safe_local_iterator & operator++()
Iterator preincrement.
pointer operator->() const
Iterator dereference.
_Safe_sequence_base * _M_sequence