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;
59 __iterator_tracker() _GLIBCXX_NOEXCEPT
60 : _M_current(), _M_ds(0) { }
62 __iterator_tracker(
const _Iterator& __i,
const _Sequence* __seq)
64 : _M_current(__i), _M_ds(__seq) { }
66 __iterator_tracker(
const __iterator_tracker& __x) _GLIBCXX_NOEXCEPT
67 : _M_current(__x._M_current), _M_ds(__x._M_ds) { }
69 template<
typename _MutableIterator>
70 __iterator_tracker(
const __iterator_tracker<_MutableIterator,
71 typename __gnu_cxx::__enable_if
72 <(std::__are_same<_MutableIterator,
typename
73 _Sequence::iterator::_Base_iterator>::__value),
74 _Sequence>::__type>& __x) _GLIBCXX_NOEXCEPT
75 : _M_current(__x.base()), _M_ds(__x._M_get_sequence()) { }
78 base() const _GLIBCXX_NOEXCEPT {
return _M_current; }
84 operator _Iterator() const _GLIBCXX_NOEXCEPT {
return _M_current; }
87 operator->() const _GLIBCXX_NOEXCEPT {
return &*_M_current; }
90 operator++() _GLIBCXX_NOEXCEPT
92 _M_ds->_M_profile_iterate();
98 operator++(
int) _GLIBCXX_NOEXCEPT
100 _M_ds->_M_profile_iterate();
101 __iterator_tracker __tmp(*
this);
107 operator--() _GLIBCXX_NOEXCEPT
109 _M_ds->_M_profile_iterate(1);
115 operator--(
int) _GLIBCXX_NOEXCEPT
117 _M_ds->_M_profile_iterate(1);
118 __iterator_tracker __tmp(*
this);
124 operator=(
const __iterator_tracker& __x) _GLIBCXX_NOEXCEPT
126 _M_current = __x._M_current;
132 {
return *_M_current; }
136 operator[](
const difference_type& __n)
const _GLIBCXX_NOEXCEPT
137 {
return _M_current[__n]; }
140 operator+=(
const difference_type& __n) _GLIBCXX_NOEXCEPT
147 operator+(
const difference_type& __n)
const _GLIBCXX_NOEXCEPT
149 __iterator_tracker __tmp(*
this);
155 operator-=(
const difference_type& __n) _GLIBCXX_NOEXCEPT
162 operator-(
const difference_type& __n)
const _GLIBCXX_NOEXCEPT
164 __iterator_tracker __tmp(*
this);
171 { _M_ds->_M_profile_find(); }
174 _M_get_sequence()
const
175 {
return static_cast<const _Sequence*
>(_M_ds); }
178 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
180 operator==(
const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
181 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
183 {
return __lhs.base() == __rhs.base(); }
185 template<
typename _Iterator,
typename _Sequence>
187 operator==(
const __iterator_tracker<_Iterator, _Sequence>& __lhs,
188 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
190 {
return __lhs.base() == __rhs.base(); }
192 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
194 operator!=(
const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
195 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
197 {
return __lhs.base() != __rhs.base(); }
199 template<
typename _Iterator,
typename _Sequence>
201 operator!=(
const __iterator_tracker<_Iterator, _Sequence>& __lhs,
202 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
204 {
return __lhs.base() != __rhs.base(); }
206 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
208 operator<(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
209 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
211 {
return __lhs.base() < __rhs.base(); }
213 template<
typename _Iterator,
typename _Sequence>
215 operator<(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
216 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
218 {
return __lhs.base() < __rhs.base(); }
220 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
222 operator<=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
223 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
225 {
return __lhs.base() <= __rhs.base(); }
227 template<
typename _Iterator,
typename _Sequence>
229 operator<=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
230 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
232 {
return __lhs.base() <= __rhs.base(); }
234 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
236 operator>(
const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
237 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
239 {
return __lhs.base() > __rhs.base(); }
241 template<
typename _Iterator,
typename _Sequence>
243 operator>(
const __iterator_tracker<_Iterator, _Sequence>& __lhs,
244 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
246 {
return __lhs.base() > __rhs.base(); }
248 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
250 operator>=(
const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
251 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
253 {
return __lhs.base() >= __rhs.base(); }
255 template<
typename _Iterator,
typename _Sequence>
257 operator>=(
const __iterator_tracker<_Iterator, _Sequence>& __lhs,
258 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
260 {
return __lhs.base() >= __rhs.base(); }
266 template<
typename _IteratorL,
typename _IteratorR,
typename _Sequence>
267 inline typename __iterator_tracker<_IteratorL, _Sequence>::difference_type
268 operator-(
const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
269 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
271 {
return __lhs.base() - __rhs.base(); }
273 template<
typename _Iterator,
typename _Sequence>
274 inline typename __iterator_tracker<_Iterator, _Sequence>::difference_type
275 operator-(
const __iterator_tracker<_Iterator, _Sequence>& __lhs,
276 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
278 {
return __lhs.base() - __rhs.base(); }
280 template<
typename _Iterator,
typename _Sequence>
281 inline __iterator_tracker<_Iterator, _Sequence>
282 operator+(
typename __iterator_tracker<_Iterator,_Sequence>::difference_type
284 const __iterator_tracker<_Iterator, _Sequence>& __i)
286 {
return __i + __n; }
complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
reference operator[](size_t __position)
Array-indexing support.