File indexing completed on 2025-01-18 09:43:31
0001
0002
0003
0004
0005
0006 #ifndef BOOST_INT_ITERATOR_H
0007 #define BOOST_INT_ITERATOR_H
0008
0009 #if !defined BOOST_MSVC
0010 #include <boost/operators.hpp>
0011 #endif
0012 #include <iostream>
0013 #include <iterator>
0014 #include <cstddef>
0015
0016
0017 #ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
0018 namespace boost {
0019 namespace iterators {
0020 #endif
0021
0022
0023
0024 template <class IntT>
0025 class int_iterator
0026 {
0027 typedef int_iterator self;
0028 public:
0029 typedef std::random_access_iterator_tag iterator_category;
0030 typedef IntT value_type;
0031 typedef IntT& reference;
0032 typedef IntT* pointer;
0033 typedef std::ptrdiff_t difference_type;
0034
0035 inline int_iterator() : _i(0) { }
0036 inline int_iterator(IntT i) : _i(i) { }
0037 inline int_iterator(const self& x) : _i(x._i) { }
0038 inline self& operator=(const self& x) { _i = x._i; return *this; }
0039 inline IntT operator*() { return _i; }
0040 inline IntT operator[](IntT n) { return _i + n; }
0041 inline self& operator++() { ++_i; return *this; }
0042 inline self operator++(int) { self t = *this; ++_i; return t; }
0043 inline self& operator+=(IntT n) { _i += n; return *this; }
0044 inline self operator+(IntT n) { self t = *this; t += n; return t; }
0045 inline self& operator--() { --_i; return *this; }
0046 inline self operator--(int) { self t = *this; --_i; return t; }
0047 inline self& operator-=(IntT n) { _i -= n; return *this; }
0048 inline IntT operator-(const self& x) const { return _i - x._i; }
0049 inline bool operator==(const self& x) const { return _i == x._i; }
0050
0051
0052 inline bool operator!=(const self& x) const { return _i != x._i; }
0053 inline bool operator<(const self& x) const { return _i < x._i; }
0054 inline bool operator<=(const self& x) const { return _i <= x._i; }
0055 inline bool operator>(const self& x) const { return _i > x._i; }
0056 inline bool operator>=(const self& x) const { return _i >= x._i; }
0057 protected:
0058 IntT _i;
0059 };
0060
0061 template <class IntT>
0062 inline int_iterator<IntT>
0063 operator+(IntT n, int_iterator<IntT> t) { t += n; return t; }
0064
0065 #ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
0066 }
0067
0068 using iterators::int_iterator;
0069
0070 }
0071 #endif
0072
0073 #ifdef BOOST_NO_OPERATORS_IN_NAMESPACE
0074 namespace boost {
0075 using ::int_iterator;
0076 namespace iterators {
0077 using ::int_iterator;
0078 }}
0079 #endif
0080
0081
0082 #endif