29 #ifndef _GLIBCXX_PROFILE_ITERATOR_TRACKER
30 #define _GLIBCXX_PROFILE_ITERATOR_TRACKER 1
34 namespace std _GLIBCXX_VISIBILITY(default)
39 template<
typename _Iterator,
typename _Sequence>
40 class __iterator_tracker
42 typedef __iterator_tracker _Self;
48 const _Sequence* _M_ds;
49 typedef std::iterator_traits<_Iterator> _Traits;
52 typedef _Iterator _Base_iterator;
53 typedef typename _Traits::iterator_category iterator_category;
54 typedef typename _Traits::value_type value_type;
55 typedef typename _Traits::difference_type difference_type;
56 typedef typename _Traits::reference reference;
57 typedef typename _Traits::pointer pointer;
60 : _M_current(), _M_ds(0) { }
62 __iterator_tracker(
const _Iterator& __i,
const _Sequence* __seq)
63 : _M_current(__i), _M_ds(__seq) { }
65 __iterator_tracker(
const __iterator_tracker& __x)
66 : _M_current(__x._M_current), _M_ds(__x._M_ds) { }
68 template<
typename _MutableIterator>
69 __iterator_tracker(
const __iterator_tracker<_MutableIterator,
70 typename __gnu_cxx::__enable_if
71 <(std::__are_same<_MutableIterator,
typename
72 _Sequence::iterator::_Base_iterator>::__value),
73 _Sequence>::__type>& __x)
74 : _M_current(__x.base()), _M_ds(__x._M_get_sequence()) { }
77 base()
const {
return _M_current; }
83 operator _Iterator()
const {
return _M_current; }
86 operator->()
const {
return &*_M_current; }
91 _M_ds->_M_profile_iterate();
99 _M_ds->_M_profile_iterate();
100 __iterator_tracker __tmp(*
this);
108 _M_ds->_M_profile_iterate(1);
116 _M_ds->_M_profile_iterate(1);
117 __iterator_tracker __tmp(*
this);
123 operator=(
const __iterator_tracker& __x)
125 _M_current = __x._M_current;
131 {
return *_M_current; }
136 {
return _M_current[__n]; }
139 operator+=(
const difference_type& __n)
146 operator+(
const difference_type& __n)
const
148 __iterator_tracker __tmp(*
this);
154 operator-=(
const difference_type& __n)
161 operator-(
const difference_type& __n)
const
163 __iterator_tracker __tmp(*
this);
170 { _M_ds->_M_profile_find(); }
173 _M_get_sequence()
const
174 {
return static_cast<const _Sequence*
>(_M_ds); }
177 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
179 operator==(
const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
180 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
181 {
return __lhs.base() == __rhs.base(); }
183 template<
typename _Iterator,
typename _Sequence>
185 operator==(
const __iterator_tracker<_Iterator, _Sequence>& __lhs,
186 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
187 {
return __lhs.base() == __rhs.base(); }
189 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
191 operator!=(
const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
192 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
193 {
return __lhs.base() != __rhs.base(); }
195 template<
typename _Iterator,
typename _Sequence>
197 operator!=(
const __iterator_tracker<_Iterator, _Sequence>& __lhs,
198 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
199 {
return __lhs.base() != __rhs.base(); }
201 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
203 operator<(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
204 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
205 {
return __lhs.base() < __rhs.base(); }
207 template<
typename _Iterator,
typename _Sequence>
209 operator<(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
210 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
211 {
return __lhs.base() < __rhs.base(); }
213 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
215 operator<=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
216 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
217 {
return __lhs.base() <= __rhs.base(); }
219 template<
typename _Iterator,
typename _Sequence>
221 operator<=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
222 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
223 {
return __lhs.base() <= __rhs.base(); }
225 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
227 operator>(
const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
228 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
229 {
return __lhs.base() > __rhs.base(); }
231 template<
typename _Iterator,
typename _Sequence>
233 operator>(
const __iterator_tracker<_Iterator, _Sequence>& __lhs,
234 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
235 {
return __lhs.base() > __rhs.base(); }
237 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
239 operator>=(
const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
240 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
241 {
return __lhs.base() >= __rhs.base(); }
243 template<
typename _Iterator,
typename _Sequence>
245 operator>=(
const __iterator_tracker<_Iterator, _Sequence>& __lhs,
246 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
247 {
return __lhs.base() >= __rhs.base(); }
253 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
254 inline typename __iterator_tracker<_IteratorL, _Sequence>::difference_type
255 operator-(
const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
256 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
257 {
return __lhs.base() - __rhs.base(); }
259 template<
typename _Iterator,
typename _Sequence>
260 inline typename __iterator_tracker<_Iterator, _Sequence>::difference_type
261 operator-(
const __iterator_tracker<_Iterator, _Sequence>& __lhs,
262 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
263 {
return __lhs.base() - __rhs.base(); }
265 template<
typename _Iterator,
typename _Sequence>
266 inline __iterator_tracker<_Iterator, _Sequence>
267 operator+(
typename __iterator_tracker<_Iterator,_Sequence>::difference_type
269 const __iterator_tracker<_Iterator, _Sequence>& __i)
270 {
return __i + __n; }