Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:43:31

0001 //  (C) Copyright Jeremy Siek 1999.
0002 //  Distributed under the Boost Software License, Version 1.0. (See
0003 //  accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
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 //using namespace std;
0016 
0017 #ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
0018 namespace boost {
0019 namespace iterators {
0020 #endif
0021 
0022 // this should use random_access_iterator_helper but I've had
0023 // VC++ portablility problems with that. -JGS
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   // vc++ had a problem finding != in random_access_iterator_helper
0051   // need to look into this... for now implementing everything here -JGS
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 } /* namespace iterators */
0067 
0068 using iterators::int_iterator;
0069 
0070 } /* namespace boost */
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 /* BOOST_INT_ITERATOR_H */