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 :
public _Safe_local_iterator_base
55 typedef typename _Sequence::const_local_iterator _Const_local_iterator;
56 typedef typename _Sequence::size_type size_type;
65 return std::__are_same<_Const_local_iterator,
69 typedef std::iterator_traits<_Iterator> _Traits;
72 typedef _Iterator iterator_type;
73 typedef typename _Traits::iterator_category iterator_category;
74 typedef typename _Traits::value_type value_type;
75 typedef typename _Traits::difference_type difference_type;
76 typedef typename _Traits::reference reference;
77 typedef typename _Traits::pointer pointer;
93 _M_message(__msg_init_singular)
94 ._M_iterator(*
this,
"this"));
102 _M_current(__x._M_current)
106 _GLIBCXX_DEBUG_VERIFY(!__x._M_singular()
107 || __x.base() == _Iterator(),
108 _M_message(__msg_init_copy_singular)
109 ._M_iterator(*
this,
"this")
110 ._M_iterator(__x,
"other"));
117 template<
typename _MutableIterator>
120 typename __gnu_cxx::__enable_if<std::__are_same<
122 typename _Sequence::local_iterator::iterator_type>::__value,
123 _Sequence>::__type>& __x)
125 _M_current(__x.
base())
129 _GLIBCXX_DEBUG_VERIFY(!__x._M_singular()
130 || __x.base() == _Iterator(),
131 _M_message(__msg_init_const_singular)
132 ._M_iterator(*
this,
"this")
133 ._M_iterator(__x,
"other"));
144 _GLIBCXX_DEBUG_VERIFY(!__x._M_singular()
145 || __x.base() == _Iterator(),
146 _M_message(__msg_copy_singular)
147 ._M_iterator(*
this,
"this")
148 ._M_iterator(__x,
"other"));
149 _M_current = __x._M_current;
162 _M_message(__msg_bad_deref)
163 ._M_iterator(*
this,
"this"));
176 _M_message(__msg_bad_deref)
177 ._M_iterator(*
this,
"this"));
190 _M_message(__msg_bad_inc)
191 ._M_iterator(*
this,
"this"));
204 _M_message(__msg_bad_inc)
205 ._M_iterator(*
this,
"this"));
216 base()
const {
return _M_current; }
222 bucket()
const {
return _M_current._M_bucket; }
228 operator _Iterator()
const {
return _M_current; }
256 __gnu_cxx::__conditional_type<std::__are_same<_Const_local_iterator,
260 _M_get_sequence()
const
265 {
return base() == _M_get_sequence()->_M_base().begin(
bucket()); }
269 {
return base() == _M_get_sequence()->_M_base().end(
bucket()); }
272 template<
typename _Other>
275 _Sequence>& __other)
const
276 {
return bucket() == __other.bucket(); }
279 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
281 operator==(
const _Safe_local_iterator<_IteratorL, _Sequence>& __lhs,
282 const _Safe_local_iterator<_IteratorR, _Sequence>& __rhs)
284 _GLIBCXX_DEBUG_VERIFY(!__lhs._M_singular() && !__rhs._M_singular(),
285 _M_message(__msg_iter_compare_bad)
286 ._M_iterator(__lhs,
"lhs")
287 ._M_iterator(__rhs,
"rhs"));
288 _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
289 _M_message(__msg_compare_different)
290 ._M_iterator(__lhs,
"lhs")
291 ._M_iterator(__rhs,
"rhs"));
292 _GLIBCXX_DEBUG_VERIFY(__lhs._M_in_same_bucket(__rhs),
293 _M_message(__msg_local_iter_compare_bad)
294 ._M_iterator(__lhs,
"lhs")
295 ._M_iterator(__rhs,
"rhs"));
296 return __lhs.base() == __rhs.base();
299 template<
typename _Iterator,
typename _Sequence>
301 operator==(
const _Safe_local_iterator<_Iterator, _Sequence>& __lhs,
302 const _Safe_local_iterator<_Iterator, _Sequence>& __rhs)
304 _GLIBCXX_DEBUG_VERIFY(!__lhs._M_singular() && !__rhs._M_singular(),
305 _M_message(__msg_iter_compare_bad)
306 ._M_iterator(__lhs,
"lhs")
307 ._M_iterator(__rhs,
"rhs"));
308 _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
309 _M_message(__msg_compare_different)
310 ._M_iterator(__lhs,
"lhs")
311 ._M_iterator(__rhs,
"rhs"));
312 _GLIBCXX_DEBUG_VERIFY(__lhs._M_in_same_bucket(__rhs),
313 _M_message(__msg_local_iter_compare_bad)
314 ._M_iterator(__lhs,
"lhs")
315 ._M_iterator(__rhs,
"rhs"));
316 return __lhs.base() == __rhs.base();
319 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
321 operator!=(
const _Safe_local_iterator<_IteratorL, _Sequence>& __lhs,
322 const _Safe_local_iterator<_IteratorR, _Sequence>& __rhs)
324 _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
325 _M_message(__msg_iter_compare_bad)
326 ._M_iterator(__lhs,
"lhs")
327 ._M_iterator(__rhs,
"rhs"));
328 _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
329 _M_message(__msg_compare_different)
330 ._M_iterator(__lhs,
"lhs")
331 ._M_iterator(__rhs,
"rhs"));
332 _GLIBCXX_DEBUG_VERIFY(__lhs._M_in_same_bucket(__rhs),
333 _M_message(__msg_local_iter_compare_bad)
334 ._M_iterator(__lhs,
"lhs")
335 ._M_iterator(__rhs,
"rhs"));
336 return __lhs.base() != __rhs.base();
339 template<
typename _Iterator,
typename _Sequence>
341 operator!=(
const _Safe_local_iterator<_Iterator, _Sequence>& __lhs,
342 const _Safe_local_iterator<_Iterator, _Sequence>& __rhs)
344 _GLIBCXX_DEBUG_VERIFY(!__lhs._M_singular() && !__rhs._M_singular(),
345 _M_message(__msg_iter_compare_bad)
346 ._M_iterator(__lhs,
"lhs")
347 ._M_iterator(__rhs,
"rhs"));
348 _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
349 _M_message(__msg_compare_different)
350 ._M_iterator(__lhs,
"lhs")
351 ._M_iterator(__rhs,
"rhs"));
352 _GLIBCXX_DEBUG_VERIFY(__lhs._M_in_same_bucket(__rhs),
353 _M_message(__msg_local_iter_compare_bad)
354 ._M_iterator(__lhs,
"lhs")
355 ._M_iterator(__rhs,
"rhs"));
356 return __lhs.base() != __rhs.base();
_Safe_local_iterator & operator++()
Iterator preincrement.
_Safe_local_iterator(const _Iterator &__i, const _Sequence *__seq)
Safe iterator construction from an unsafe iterator and its sequence.
_Safe_local_iterator & operator=(const _Safe_local_iterator &__x)
Copy assignment.
void _M_attach(_Safe_sequence_base *__seq, bool __constant)
Basic functionality for a safe iterator.
_Safe_local_iterator(const _Safe_local_iterator &__x)
Copy construction.
void _M_attach_single(_Safe_sequence_base *__seq)
size_type bucket() const
Return the bucket.
Base class that supports tracking of iterators that reference a sequence.
pointer operator->() const
Iterator dereference.
bool _M_dereferenceable() const
Is the iterator dereferenceable?
bool _M_incrementable() const
Is the iterator incrementable?
_Safe_sequence_base * _M_sequence
_Iterator base() const
Return the underlying iterator.
void _M_attach_single(_Safe_sequence_base *__seq, bool __constant)
bool _M_is_end() const
Is this iterator equal to the sequence's end(bucket) iterator?
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
_Safe_local_iterator operator++(int)
Iterator postincrement.
bool _M_is_begin() const
Is this iterator equal to the sequence's begin(bucket) iterator?
_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.
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?
reference operator*() const
Iterator dereference.
void _M_attach(_Safe_sequence_base *__seq)