diff options
Diffstat (limited to 'boost/interprocess/detail/transform_iterator.hpp')
-rw-r--r-- | boost/interprocess/detail/transform_iterator.hpp | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/boost/interprocess/detail/transform_iterator.hpp b/boost/interprocess/detail/transform_iterator.hpp index 5496d19568..1c4dcd3aeb 100644 --- a/boost/interprocess/detail/transform_iterator.hpp +++ b/boost/interprocess/detail/transform_iterator.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2005-2012. +// (C) Copyright Ion Gaztanaga 2005-2015. // (C) Copyright Gennaro Prota 2003 - 2004. // // Distributed under the Boost Software License, Version 1.0. @@ -14,17 +14,23 @@ #ifndef BOOST_INTERPROCESS_DETAIL_TRANSFORM_ITERATORS_HPP #define BOOST_INTERPROCESS_DETAIL_TRANSFORM_ITERATORS_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif +# +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include <boost/interprocess/detail/config_begin.hpp> #include <boost/interprocess/detail/workaround.hpp> +// interprocess #include <boost/interprocess/interprocess_fwd.hpp> - -#include <iterator> +// interprocess/detail #include <boost/interprocess/detail/type_traits.hpp> +// move/detail +#include <boost/container/detail/iterator.hpp> namespace boost { namespace interprocess { @@ -60,14 +66,14 @@ struct operator_arrow_proxy<T&> template <class Iterator, class UnaryFunction> class transform_iterator : public UnaryFunction - , public std::iterator - < typename std::iterator_traits<Iterator>::iterator_category - , typename ipcdetail::remove_reference<typename UnaryFunction::result_type>::type - , typename std::iterator_traits<Iterator>::difference_type - , operator_arrow_proxy<typename UnaryFunction::result_type> - , typename UnaryFunction::result_type> { public: + typedef typename ::boost::container::iterator_traits<Iterator>::iterator_category iterator_category; + typedef typename ipcdetail::remove_reference<typename UnaryFunction::result_type>::type value_type; + typedef typename ::boost::container::iterator_traits<Iterator>::difference_type difference_type; + typedef operator_arrow_proxy<typename UnaryFunction::result_type> pointer; + typedef typename UnaryFunction::result_type reference; + explicit transform_iterator(const Iterator &it, const UnaryFunction &f = UnaryFunction()) : UnaryFunction(f), m_it(it) {} @@ -115,33 +121,33 @@ class transform_iterator friend bool operator>= (const transform_iterator& i, const transform_iterator& i2) { return !(i < i2); } - friend typename std::iterator_traits<Iterator>::difference_type operator- (const transform_iterator& i, const transform_iterator& i2) + friend difference_type operator- (const transform_iterator& i, const transform_iterator& i2) { return i2.distance_to(i); } //Arithmetic - transform_iterator& operator+=(typename std::iterator_traits<Iterator>::difference_type off) + transform_iterator& operator+=(difference_type off) { this->advance(off); return *this; } - transform_iterator operator+(typename std::iterator_traits<Iterator>::difference_type off) const + transform_iterator operator+(difference_type off) const { transform_iterator other(*this); other.advance(off); return other; } - friend transform_iterator operator+(typename std::iterator_traits<Iterator>::difference_type off, const transform_iterator& right) + friend transform_iterator operator+(difference_type off, const transform_iterator& right) { return right + off; } - transform_iterator& operator-=(typename std::iterator_traits<Iterator>::difference_type off) + transform_iterator& operator-=(difference_type off) { this->advance(-off); return *this; } - transform_iterator operator-(typename std::iterator_traits<Iterator>::difference_type off) const + transform_iterator operator-(difference_type off) const { return *this + (-off); } typename UnaryFunction::result_type operator*() const { return dereference(); } - typename UnaryFunction::result_type operator[](typename std::iterator_traits<Iterator>::difference_type off) const + typename UnaryFunction::result_type operator[](difference_type off) const { return UnaryFunction::operator()(m_it[off]); } operator_arrow_proxy<typename UnaryFunction::result_type> @@ -172,11 +178,11 @@ class transform_iterator typename UnaryFunction::result_type dereference() const { return UnaryFunction::operator()(*m_it); } - void advance(typename std::iterator_traits<Iterator>::difference_type n) - { std::advance(m_it, n); } + void advance(difference_type n) + { ::boost::container::iterator_advance(m_it, n); } - typename std::iterator_traits<Iterator>::difference_type distance_to(const transform_iterator &other)const - { return std::distance(other.m_it, m_it); } + difference_type distance_to(const transform_iterator &other)const + { return ::boost::container::iterator_distance(other.m_it, m_it); } }; template <class Iterator, class UnaryFunc> @@ -192,4 +198,3 @@ make_transform_iterator(Iterator it, UnaryFunc fun) #include <boost/interprocess/detail/config_end.hpp> #endif //#ifndef BOOST_INTERPROCESS_DETAIL_TRANSFORM_ITERATORS_HPP - |