GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / toolchains / hndtools-arm-linux-2.6.36-uclibc-4.5.3 / arm-brcm-linux-uclibcgnueabi / include / c++ / 4.5.3 / profile / iterator_tracker.h
blob0febb9babaee7b1949fc507c9ef6cdab467dedd0
1 // Profiling iterator implementation -*- C++ -*-
3 // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 /** @file profile/iterator_tracker.h
26 * This file is a GNU profile extension to the Standard C++ Library.
29 #ifndef _GLIBCXX_PROFILE_ITERATOR_TRACKER
30 #define _GLIBCXX_PROFILE_ITERATOR_TRACKER 1
32 #include <ext/type_traits.h>
34 namespace std
36 namespace __profile
39 template<typename _Iterator, typename _Sequence>
40 class __iterator_tracker
42 typedef __iterator_tracker _Self;
43 // The underlying iterator
44 _Iterator _M_current;
45 // The underlying data structure
46 const _Sequence* _M_ds;
47 typedef std::iterator_traits<_Iterator> _Traits;
49 public:
50 typedef _Iterator _Base_iterator;
51 typedef typename _Traits::iterator_category iterator_category;
52 typedef typename _Traits::value_type value_type;
53 typedef typename _Traits::difference_type difference_type;
54 typedef typename _Traits::reference reference;
55 typedef typename _Traits::pointer pointer;
57 __iterator_tracker() : _M_current(), _M_ds(0) { }
58 __iterator_tracker(const _Iterator& __i, const _Sequence* seq)
59 : _M_current(__i), _M_ds(seq) { }
60 __iterator_tracker(const __iterator_tracker& __x)
61 : _M_current(__x._M_current), _M_ds(__x._M_ds) { }
62 template<typename _MutableIterator>
63 __iterator_tracker(const __iterator_tracker<_MutableIterator, typename __gnu_cxx::__enable_if<(std::__are_same<_MutableIterator, typename _Sequence::iterator::_Base_iterator>::__value), _Sequence>::__type>& __x)
64 : _M_current(__x.base()), _M_ds(__x._M_get_sequence()) { }
66 _Iterator
67 base() const { return _M_current; }
68 /**
69 * @brief Conversion to underlying non-debug iterator to allow
70 * better interaction with non-profile containers.
72 operator _Iterator() const { return _M_current; }
74 pointer
75 operator->() const { return &*_M_current; }
77 __iterator_tracker&
78 operator++()
80 _M_ds->_M_profile_iterate();
81 ++_M_current;
82 return *this;
85 __iterator_tracker&
86 operator++(int)
88 _M_ds->_M_profile_iterate();
89 __iterator_tracker __tmp(*this);
90 ++_M_current;
91 return __tmp;
94 __iterator_tracker&
95 operator--()
97 _M_ds->_M_profile_iterate(1);
98 --_M_current;
99 return *this;
102 __iterator_tracker&
103 operator--(int)
105 _M_ds->_M_profile_iterate(1);
106 __iterator_tracker __tmp(*this);
107 --_M_current;
108 return __tmp;
111 __iterator_tracker&
112 operator=(const __iterator_tracker& __x)
114 _M_current = __x._M_current;
115 return *this;
118 reference
119 operator*() const
121 return *_M_current;
124 // ------ Random access iterator requirements ------
125 reference
126 operator[](const difference_type& __n) const
128 return _M_current[__n];
131 __iterator_tracker&
132 operator+=(const difference_type& __n)
134 _M_current += __n;
135 return *this;
138 __iterator_tracker
139 operator+(const difference_type& __n) const
141 __iterator_tracker __tmp(*this);
142 __tmp += __n;
143 return __tmp;
146 __iterator_tracker&
147 operator-=(const difference_type& __n)
149 _M_current += -__n;
150 return *this;
153 __iterator_tracker
154 operator-(const difference_type& __n) const
156 __iterator_tracker __tmp(*this);
157 __tmp -= __n;
158 return __tmp;
161 void
162 _M_find()
164 _M_ds->_M_profile_find();
167 const _Sequence*
168 _M_get_sequence() const
170 return static_cast<const _Sequence*>(_M_ds);
174 template<typename _IteratorL, typename _IteratorR, typename _Sequence>
175 inline bool
176 operator==(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
177 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
179 return __lhs.base() == __rhs.base();
182 template<typename _Iterator, typename _Sequence>
183 inline bool
184 operator==(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
185 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
187 return __lhs.base() == __rhs.base();
190 template<typename _IteratorL, typename _IteratorR, typename _Sequence>
191 inline bool
192 operator!=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
193 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
195 return __lhs.base() != __rhs.base();
198 template<typename _Iterator, typename _Sequence>
199 inline bool
200 operator!=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
201 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
203 return __lhs.base() != __rhs.base();
206 template<typename _IteratorL, typename _IteratorR, typename _Sequence>
207 inline bool
208 operator<(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
209 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
211 return __lhs.base() < __rhs.base();
214 template<typename _Iterator, typename _Sequence>
215 inline bool
216 operator<(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
217 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
219 return __lhs.base() < __rhs.base();
222 template<typename _IteratorL, typename _IteratorR, typename _Sequence>
223 inline bool
224 operator<=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
225 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
227 return __lhs.base() <= __rhs.base();
230 template<typename _Iterator, typename _Sequence>
231 inline bool
232 operator<=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
233 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
235 return __lhs.base() <= __rhs.base();
238 template<typename _IteratorL, typename _IteratorR, typename _Sequence>
239 inline bool
240 operator>(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
241 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
243 return __lhs.base() > __rhs.base();
246 template<typename _Iterator, typename _Sequence>
247 inline bool
248 operator>(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
249 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
251 return __lhs.base() > __rhs.base();
254 template<typename _IteratorL, typename _IteratorR, typename _Sequence>
255 inline bool
256 operator>=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
257 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
259 return __lhs.base() >= __rhs.base();
262 template<typename _Iterator, typename _Sequence>
263 inline bool
264 operator>=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
265 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
267 return __lhs.base() >= __rhs.base();
270 // _GLIBCXX_RESOLVE_LIB_DEFECTS
271 // According to the resolution of DR179 not only the various comparison
272 // operators but also operator- must accept mixed iterator/const_iterator
273 // parameters.
274 template<typename _IteratorL, typename _IteratorR, typename _Sequence>
275 inline typename __iterator_tracker<_IteratorL, _Sequence>::difference_type
276 operator-(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
277 const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
279 return __lhs.base() - __rhs.base();
282 template<typename _Iterator, typename _Sequence>
283 inline typename __iterator_tracker<_Iterator, _Sequence>::difference_type
284 operator-(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
285 const __iterator_tracker<_Iterator, _Sequence>& __rhs)
287 return __lhs.base() - __rhs.base();
290 template<typename _Iterator, typename _Sequence>
291 inline __iterator_tracker<_Iterator, _Sequence>
292 operator+(typename __iterator_tracker<_Iterator,_Sequence>::difference_type
293 __n,
294 const __iterator_tracker<_Iterator, _Sequence>& __i)
296 return __i + __n;
299 } // namespace __profile
300 } // namespace std
301 #endif