31 #ifndef __CLAW_ITERATOR_HPP__
32 #define __CLAW_ITERATOR_HPP__
43 template<
typename Category,
typename Value,
typename Iterator,
55 template<
typename Value,
typename Iterator,
typename Function>
57 <std::forward_iterator_tag, Value, Iterator, Function>
60 typedef typename std::iterator_traits<Iterator>::difference_type
62 typedef Value value_type;
63 typedef value_type* pointer;
64 typedef value_type& reference;
65 typedef typename std::iterator_traits<Iterator>::iterator_category
70 <std::forward_iterator_tag, Value, Iterator, Function>
81 template<
typename C,
typename V,
typename I,
typename F>
84 : m_it(that.get_iterator()), m_fun(that.get_function())
87 const Iterator& get_iterator()
const {
return m_it; }
88 const Function& get_function()
const {
return m_fun; }
103 reference
operator*()
const {
return m_fun(*m_it); }
104 pointer operator->()
const {
return &m_fun(*m_it); }
106 bool operator==(
const self_type& that )
const {
return m_it == that.m_it; }
107 bool operator!=(
const self_type& that )
const {
return m_it != that.m_it; }
108 bool operator==(
const Iterator& it )
const {
return m_it == it; }
109 bool operator!=(
const Iterator& it )
const {
return m_it != it; }
126 template<
typename Value,
typename Iterator,
typename Function>
128 <std::bidirectional_iterator_tag, Value, Iterator, Function>
131 typedef typename std::iterator_traits<Iterator>::difference_type
133 typedef Value value_type;
134 typedef value_type* pointer;
135 typedef value_type& reference;
136 typedef typename std::iterator_traits<Iterator>::iterator_category
141 <std::bidirectional_iterator_tag, Value, Iterator, Function>
self_type;
151 template<
typename C,
typename V,
typename I,
typename F>
154 : m_it(that.get_iterator()), m_fun(that.get_function())
157 const Iterator& get_iterator()
const {
return m_it; }
158 const Function& get_function()
const {
return m_fun; }
186 reference
operator*()
const {
return m_fun(*m_it); }
187 pointer operator->()
const {
return &m_fun(*m_it); }
189 bool operator==(
const self_type& that )
const {
return m_it == that.m_it; }
190 bool operator!=(
const self_type& that )
const {
return m_it != that.m_it; }
191 bool operator==(
const Iterator& it )
const {
return m_it == it; }
192 bool operator!=(
const Iterator& it )
const {
return m_it != it; }
208 template<
typename Value,
typename Iterator,
typename Function>
210 <std::random_access_iterator_tag, Value, Iterator, Function>
213 typedef typename std::iterator_traits<Iterator>::difference_type
215 typedef Value value_type;
216 typedef value_type* pointer;
217 typedef value_type& reference;
218 typedef typename std::iterator_traits<Iterator>::iterator_category
223 <std::random_access_iterator_tag, Value, Iterator, Function>
234 template<
typename V,
typename I>
237 <std::random_access_iterator_tag, V, I, Function>& that )
238 : m_it(that.m_it), m_fun(that.m_fun)
240 template<
typename C,
typename V,
typename I,
typename F>
243 : m_it(that.get_iterator()), m_fun(that.get_function())
246 const Iterator& get_iterator()
const {
return m_it; }
247 const Function& get_function()
const {
return m_fun; }
275 reference
operator*()
const {
return m_fun(*m_it); }
276 pointer operator->()
const {
return &m_fun(*m_it); }
278 bool operator==(
const self_type& that )
const {
return m_it == that.m_it; }
279 bool operator!=(
const self_type& that )
const {
return m_it != that.m_it; }
280 bool operator==(
const Iterator& it )
const {
return m_it == it; }
281 bool operator!=(
const Iterator& it )
const {
return m_it != it; }
282 bool operator<(
const self_type& that )
const {
return m_it < that.m_it; }
283 bool operator<=(
const self_type& that )
const {
return m_it <= that.m_it; }
284 bool operator>(
const self_type& that )
const {
return m_it > that.m_it; }
285 bool operator>=(
const self_type& that )
const {
return m_it >= that.m_it; }
300 self_type& operator-=(
int n) {
return *
this += -n; }
309 reference operator[](
int n) {
return m_fun(m_it[n]); }
320 template<
typename Value,
typename Iterator,
typename Function>
322 <std::random_access_iterator_tag, Value, Iterator, Function>
326 < std::random_access_iterator_tag, Value, Iterator, Function >& it )
331 template<
typename Value,
typename Iterator,
typename Function>
332 wrapped_iterator_by_category
333 <std::random_access_iterator_tag, Value, Iterator, Function>
336 const wrapped_iterator_by_category
337 < std::random_access_iterator_tag, Value, Iterator, Function >& it )
355 template <
typename Value,
typename Iterator,
typename Function>
361 <
typename std::iterator_traits<Iterator>::iterator_category,
362 Value, Iterator, Function >
368 #endif // __CLAW_ITERATOR_HPP__