1 // (C) Copyright David Abrahams 2002.
\r
2 // (C) Copyright Jeremy Siek 2002.
\r
3 // (C) Copyright Thomas Witt 2002.
\r
4 // Distributed under the Boost Software License, Version 1.0. (See
\r
5 // accompanying file LICENSE_1_0.txt or copy at
\r
6 // http://www.boost.org/LICENSE_1_0.txt)
\r
7 #ifndef BOOST_REVERSE_ITERATOR_23022003THW_HPP
\r
8 #define BOOST_REVERSE_ITERATOR_23022003THW_HPP
\r
10 #include <boost/iterator.hpp>
\r
11 #include <boost/utility.hpp>
\r
12 #include <boost/iterator/iterator_adaptor.hpp>
\r
20 template <class Iterator>
\r
21 class reverse_iterator
\r
22 : public iterator_adaptor< reverse_iterator<Iterator>, Iterator >
\r
24 typedef iterator_adaptor< reverse_iterator<Iterator>, Iterator > super_t;
\r
26 friend class iterator_core_access;
\r
29 reverse_iterator() {}
\r
31 explicit reverse_iterator(Iterator x)
\r
34 template<class OtherIterator>
\r
36 reverse_iterator<OtherIterator> const& r
\r
37 , typename enable_if_convertible<OtherIterator, Iterator>::type* = 0
\r
43 typename super_t::reference dereference() const { return *boost::prior(this->base()); }
\r
45 void increment() { --this->base_reference(); }
\r
46 void decrement() { ++this->base_reference(); }
\r
48 void advance(typename super_t::difference_type n)
\r
50 this->base_reference() += -n;
\r
53 template <class OtherIterator>
\r
54 typename super_t::difference_type
\r
55 distance_to(reverse_iterator<OtherIterator> const& y) const
\r
57 return this->base_reference() - y.base();
\r
61 template <class BidirectionalIterator>
\r
62 reverse_iterator<BidirectionalIterator> make_reverse_iterator(BidirectionalIterator x)
\r
64 return reverse_iterator<BidirectionalIterator>(x);
\r
67 } // namespace boost
\r
69 #endif // BOOST_REVERSE_ITERATOR_23022003THW_HPP
\r