Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:40:53

0001 /////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga  2014-2014
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 //    (See accompanying file LICENSE_1_0.txt or copy at
0007 //          http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // See http://www.boost.org/libs/move for documentation.
0010 //
0011 /////////////////////////////////////////////////////////////////////////////
0012 
0013 #ifndef BOOST_MOVE_DETAIL_REVERSE_ITERATOR_HPP
0014 #define BOOST_MOVE_DETAIL_REVERSE_ITERATOR_HPP
0015 
0016 #ifndef BOOST_CONFIG_HPP
0017 #  include <boost/config.hpp>
0018 #endif
0019 
0020 #if defined(BOOST_HAS_PRAGMA_ONCE)
0021 #  pragma once
0022 #endif
0023 
0024 #include <boost/move/detail/config_begin.hpp>
0025 #include <boost/move/detail/iterator_traits.hpp>
0026 #include <boost/move/detail/meta_utils.hpp>
0027 
0028 namespace boost {
0029 namespace movelib {
0030 
0031 template<class I>
0032 BOOST_MOVE_FORCEINLINE typename iterator_traits<I>::pointer iterator_arrow_result(const I &i)
0033 {  return i.operator->();  }
0034 
0035 template<class T>
0036 BOOST_MOVE_FORCEINLINE T * iterator_arrow_result(T *p)
0037 {  return p;   }
0038 
0039 template<class It>
0040 class reverse_iterator
0041 {
0042    public:
0043    typedef typename boost::movelib::iterator_traits<It>::pointer             pointer;
0044    typedef typename boost::movelib::iterator_traits<It>::reference           reference;
0045    typedef typename boost::movelib::iterator_traits<It>::difference_type     difference_type;
0046    typedef typename boost::movelib::iterator_traits<It>::iterator_category   iterator_category;
0047    typedef typename boost::movelib::iterator_traits<It>::value_type          value_type;
0048 
0049 
0050    typedef It iterator_type;
0051 
0052    BOOST_MOVE_FORCEINLINE reverse_iterator()
0053       : m_current()  //Value initialization to achieve "null iterators" (N3644)
0054    {}
0055 
0056    BOOST_MOVE_FORCEINLINE explicit reverse_iterator(It r)
0057       : m_current(r)
0058    {}
0059 
0060    BOOST_MOVE_FORCEINLINE reverse_iterator(const reverse_iterator& r)
0061       : m_current(r.base())
0062    {}
0063 
0064    template<class OtherIt>
0065    BOOST_MOVE_FORCEINLINE
0066       reverse_iterator( const reverse_iterator<OtherIt>& r
0067                       , typename boost::move_detail::enable_if_convertible<OtherIt, It>::type* =0
0068                    )
0069       : m_current(r.base())
0070    {}
0071 
0072    BOOST_MOVE_FORCEINLINE reverse_iterator & operator=( const reverse_iterator& r)
0073    {  m_current = r.base();   return *this;  }
0074 
0075    template<class OtherIt>
0076    BOOST_MOVE_FORCEINLINE typename boost::move_detail::enable_if_convertible<OtherIt, It, reverse_iterator &>::type
0077          operator=( const reverse_iterator<OtherIt>& r)
0078    {  m_current = r.base();   return *this;  }
0079 
0080    BOOST_MOVE_FORCEINLINE It base() const
0081    {  return m_current;  }
0082 
0083    BOOST_MOVE_FORCEINLINE reference operator*() const
0084    {
0085       It temp(m_current);
0086       --temp;
0087       reference r = *temp;
0088       return r;
0089    }
0090 
0091    BOOST_MOVE_FORCEINLINE pointer operator->() const
0092    {
0093       It temp(m_current);
0094       --temp;
0095       return (iterator_arrow_result)(temp);
0096    }
0097 
0098    BOOST_MOVE_FORCEINLINE reference operator[](difference_type off) const
0099    {
0100       return this->m_current[difference_type(-off - 1)];
0101    }
0102 
0103    BOOST_MOVE_FORCEINLINE reverse_iterator& operator++()
0104    {
0105       --m_current;
0106       return *this;
0107    }
0108 
0109    BOOST_MOVE_FORCEINLINE reverse_iterator operator++(int)
0110    {
0111       reverse_iterator temp((*this));
0112       --m_current;
0113       return temp;
0114    }
0115 
0116    BOOST_MOVE_FORCEINLINE reverse_iterator& operator--()
0117    {
0118       ++m_current;
0119       return *this;
0120    }
0121 
0122    BOOST_MOVE_FORCEINLINE reverse_iterator operator--(int)
0123    {
0124       reverse_iterator temp((*this));
0125       ++m_current;
0126       return temp;
0127    }
0128 
0129    BOOST_MOVE_FORCEINLINE friend bool operator==(const reverse_iterator& l, const reverse_iterator& r)
0130    {  return l.m_current == r.m_current;  }
0131 
0132    BOOST_MOVE_FORCEINLINE friend bool operator!=(const reverse_iterator& l, const reverse_iterator& r)
0133    {  return l.m_current != r.m_current;  }
0134 
0135    BOOST_MOVE_FORCEINLINE friend bool operator<(const reverse_iterator& l, const reverse_iterator& r)
0136    {  return l.m_current > r.m_current;  }
0137 
0138    BOOST_MOVE_FORCEINLINE friend bool operator<=(const reverse_iterator& l, const reverse_iterator& r)
0139    {  return l.m_current >= r.m_current;  }
0140 
0141    BOOST_MOVE_FORCEINLINE friend bool operator>(const reverse_iterator& l, const reverse_iterator& r)
0142    {  return l.m_current < r.m_current;  }
0143 
0144    BOOST_MOVE_FORCEINLINE friend bool operator>=(const reverse_iterator& l, const reverse_iterator& r)
0145    {  return l.m_current <= r.m_current;  }
0146 
0147    BOOST_MOVE_FORCEINLINE reverse_iterator& operator+=(difference_type off)
0148    {  m_current -= off; return *this;  }
0149 
0150    BOOST_MOVE_FORCEINLINE reverse_iterator& operator-=(difference_type off)
0151    {  m_current += off; return *this;  }
0152 
0153    BOOST_MOVE_FORCEINLINE friend reverse_iterator operator+(reverse_iterator l, difference_type off)
0154    {  return (l += off);  }
0155 
0156    BOOST_MOVE_FORCEINLINE friend reverse_iterator operator+(difference_type off, reverse_iterator r)
0157    {  return (r += off);   }
0158 
0159    BOOST_MOVE_FORCEINLINE friend reverse_iterator operator-(reverse_iterator l, difference_type off)
0160    {  return (l-= off);  }
0161 
0162    BOOST_MOVE_FORCEINLINE friend difference_type operator-(const reverse_iterator& l, const reverse_iterator& r)
0163    {  return r.m_current - l.m_current;  }
0164 
0165    private:
0166    It m_current;   // the wrapped iterator
0167 };
0168 
0169 template< class Iterator >
0170 BOOST_MOVE_FORCEINLINE reverse_iterator<Iterator> make_reverse_iterator( Iterator i )
0171 {  return reverse_iterator<Iterator>(i);  }
0172 
0173 } //namespace movelib {
0174 } //namespace boost {
0175 
0176 #include <boost/move/detail/config_end.hpp>
0177 
0178 #endif //BOOST_MOVE_DETAIL_REVERSE_ITERATOR_HPP