1 // (C) Copyright Jeremy Siek 1999.
2 // Distributed under the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef BOOST_INT_ITERATOR_H
7 #define BOOST_INT_ITERATOR_H
9 #include <boost/iterator.hpp>
10 #if !defined BOOST_MSVC
11 #include <boost/operators.hpp>
14 //using namespace std;
16 #ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
21 // this should use random_access_iterator_helper but I've had
22 // VC++ portablility problems with that. -JGS
26 typedef int_iterator self;
28 typedef std::random_access_iterator_tag iterator_category;
29 typedef IntT value_type;
30 typedef IntT& reference;
31 typedef IntT* pointer;
32 typedef std::ptrdiff_t difference_type;
34 inline int_iterator() : _i(0) { }
35 inline int_iterator(IntT i) : _i(i) { }
36 inline int_iterator(const self& x) : _i(x._i) { }
37 inline self& operator=(const self& x) { _i = x._i; return *this; }
38 inline IntT operator*() { return _i; }
39 inline IntT operator[](IntT n) { return _i + n; }
40 inline self& operator++() { ++_i; return *this; }
41 inline self operator++(int) { self t = *this; ++_i; return t; }
42 inline self& operator+=(IntT n) { _i += n; return *this; }
43 inline self operator+(IntT n) { self t = *this; t += n; return t; }
44 inline self& operator--() { --_i; return *this; }
45 inline self operator--(int) { self t = *this; --_i; return t; }
46 inline self& operator-=(IntT n) { _i -= n; return *this; }
47 inline IntT operator-(const self& x) const { return _i - x._i; }
48 inline bool operator==(const self& x) const { return _i == x._i; }
49 // vc++ had a problem finding != in random_access_iterator_helper
50 // need to look into this... for now implementing everything here -JGS
51 inline bool operator!=(const self& x) const { return _i != x._i; }
52 inline bool operator<(const self& x) const { return _i < x._i; }
53 inline bool operator<=(const self& x) const { return _i <= x._i; }
54 inline bool operator>(const self& x) const { return _i > x._i; }
55 inline bool operator>=(const self& x) const { return _i >= x._i; }
61 inline int_iterator<IntT>
62 operator+(IntT n, int_iterator<IntT> t) { t += n; return t; }
64 #ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
65 } /* namespace iterators */
67 using iterators::int_iterator;
69 } /* namespace boost */
72 #ifdef BOOST_NO_OPERATORS_IN_NAMESPACE
81 #endif /* BOOST_INT_ITERATOR_H */