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::size_type size_type;
67 typedef typename _Sequence::const_local_iterator const_iterator;
68 return std::__are_same<const_iterator, _Safe_local_iterator>::__value;
71 typedef std::iterator_traits<_Iterator> _Traits;
74 typedef _Iterator iterator_type;
75 typedef typename _Traits::iterator_category iterator_category;
76 typedef typename _Traits::value_type value_type;
77 typedef typename _Traits::difference_type difference_type;
78 typedef typename _Traits::reference reference;
79 typedef typename _Traits::pointer pointer;
92 const _Sequence* __seq)
97 _M_message(__msg_init_singular)
98 ._M_iterator(*
this,
"this"));
106 _M_current(__x._M_current), _M_bucket(__x._M_bucket)
110 _GLIBCXX_DEBUG_VERIFY(!__x._M_singular()
111 || __x._M_current == _Iterator(),
112 _M_message(__msg_init_copy_singular)
113 ._M_iterator(*
this,
"this")
114 ._M_iterator(__x,
"other"));
121 template<
typename _MutableIterator>
124 typename __gnu_cxx::__enable_if<std::__are_same<
126 typename _Sequence::local_iterator::iterator_type>::__value,
127 _Sequence>::__type>& __x)
129 _M_current(__x.
base()), _M_bucket(__x._M_bucket)
133 _GLIBCXX_DEBUG_VERIFY(!__x._M_singular()
134 || __x.base() == _Iterator(),
135 _M_message(__msg_init_const_singular)
136 ._M_iterator(*
this,
"this")
137 ._M_iterator(__x,
"other"));
148 _GLIBCXX_DEBUG_VERIFY(!__x._M_singular()
149 || __x._M_current == _Iterator(),
150 _M_message(__msg_copy_singular)
151 ._M_iterator(*
this,
"this")
152 ._M_iterator(__x,
"other"));
153 _M_current = __x._M_current;
154 _M_bucket = __x._M_bucket;
167 _M_message(__msg_bad_deref)
168 ._M_iterator(*
this,
"this"));
182 _M_message(__msg_bad_deref)
183 ._M_iterator(*
this,
"this"));
196 _M_message(__msg_bad_inc)
197 ._M_iterator(*
this,
"this"));
210 _M_message(__msg_bad_inc)
211 ._M_iterator(*
this,
"this"));
222 base()
const {
return _M_current; }
234 operator _Iterator()
const {
return _M_current; }
257 template<
typename _Other>
260 _Sequence>& __rhs)
const;
264 _M_get_sequence()
const
265 {
return static_cast<const _Sequence*
>(
_M_sequence); }
269 {
return base() == _M_get_sequence()->_M_base().begin(_M_bucket); }
273 {
return base() == _M_get_sequence()->_M_base().end(_M_bucket); }
276 template <
typename _Other>
278 _Sequence>& __other)
const
279 {
return _M_bucket == __other.bucket(); }
282 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
284 operator==(
const _Safe_local_iterator<_IteratorL, _Sequence>& __lhs,
285 const _Safe_local_iterator<_IteratorR, _Sequence>& __rhs)
287 _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
288 _M_message(__msg_iter_compare_bad)
289 ._M_iterator(__lhs,
"lhs")
290 ._M_iterator(__rhs,
"rhs"));
291 _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
292 _M_message(__msg_compare_different)
293 ._M_iterator(__lhs,
"lhs")
294 ._M_iterator(__rhs,
"rhs"));
295 _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
296 _M_message(__msg_compare_different)
297 ._M_iterator(__lhs,
"lhs")
298 ._M_iterator(__rhs,
"rhs"));
299 _GLIBCXX_DEBUG_VERIFY(__lhs._M_in_same_bucket(__rhs),
300 _M_message(__msg_local_iter_compare_bad)
301 ._M_iterator(__lhs,
"lhs")
302 ._M_iterator(__rhs,
"rhs"));
303 return __lhs.base() == __rhs.base();
306 template<
typename _Iterator,
typename _Sequence>
308 operator==(
const _Safe_local_iterator<_Iterator, _Sequence>& __lhs,
309 const _Safe_local_iterator<_Iterator, _Sequence>& __rhs)
311 _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
312 _M_message(__msg_iter_compare_bad)
313 ._M_iterator(__lhs,
"lhs")
314 ._M_iterator(__rhs,
"rhs"));
315 _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
316 _M_message(__msg_compare_different)
317 ._M_iterator(__lhs,
"lhs")
318 ._M_iterator(__rhs,
"rhs"));
319 _GLIBCXX_DEBUG_VERIFY(__lhs._M_in_same_bucket(__rhs),
320 _M_message(__msg_local_iter_compare_bad)
321 ._M_iterator(__lhs,
"lhs")
322 ._M_iterator(__rhs,
"rhs"));
323 return __lhs.base() == __rhs.base();
326 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
328 operator!=(
const _Safe_local_iterator<_IteratorL, _Sequence>& __lhs,
329 const _Safe_local_iterator<_IteratorR, _Sequence>& __rhs)
331 _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
332 _M_message(__msg_iter_compare_bad)
333 ._M_iterator(__lhs,
"lhs")
334 ._M_iterator(__rhs,
"rhs"));
335 _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
336 _M_message(__msg_compare_different)
337 ._M_iterator(__lhs,
"lhs")
338 ._M_iterator(__rhs,
"rhs"));
339 _GLIBCXX_DEBUG_VERIFY(__lhs._M_in_same_bucket(__rhs),
340 _M_message(__msg_local_iter_compare_bad)
341 ._M_iterator(__lhs,
"lhs")
342 ._M_iterator(__rhs,
"rhs"));
343 return __lhs.base() != __rhs.base();
346 template<
typename _Iterator,
typename _Sequence>
348 operator!=(
const _Safe_local_iterator<_Iterator, _Sequence>& __lhs,
349 const _Safe_local_iterator<_Iterator, _Sequence>& __rhs)
351 _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
352 _M_message(__msg_iter_compare_bad)
353 ._M_iterator(__lhs,
"lhs")
354 ._M_iterator(__rhs,
"rhs"));
355 _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
356 _M_message(__msg_compare_different)
357 ._M_iterator(__lhs,
"lhs")
358 ._M_iterator(__rhs,
"rhs"));
359 _GLIBCXX_DEBUG_VERIFY(__lhs._M_in_same_bucket(__rhs),
360 _M_message(__msg_local_iter_compare_bad)
361 ._M_iterator(__lhs,
"lhs")
362 ._M_iterator(__rhs,
"rhs"));
363 return __lhs.base() != __rhs.base();
_Safe_local_iterator & operator++()
Iterator preincrement.
_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.
_Safe_local_iterator(const _Iterator &__i, size_type __bucket, const _Sequence *__seq)
Safe iterator construction from an unsafe iterator and its 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() iterator?
_Safe_local_iterator operator++(int)
Iterator postincrement.
bool _M_is_begin() const
Is this iterator equal to the sequence's begin() 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)