mirror of
https://github.com/boostorg/iterator.git
synced 2025-07-03 15:56:46 +02:00
Compare commits
11 Commits
svn-branch
...
boost-1.18
Author | SHA1 | Date | |
---|---|---|---|
b3a3407c52 | |||
efcbd24229 | |||
3692175786 | |||
d3b8f893bc | |||
cebe553621 | |||
b54236986d | |||
24c3beb791 | |||
50c9214b82 | |||
c583cf8730 | |||
61d2d43ea5 | |||
76efd2456c |
@ -13,10 +13,16 @@
|
||||
#ifndef BOOST_INTEGER_RANGE_HPP_
|
||||
#define BOOST_INTEGER_RANGE_HPP_
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#include <boost/pending/detail/int_iterator.hpp>
|
||||
#else
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if !defined(BOOST_MSVC) || defined(__SGI_STL_PORT)
|
||||
#define BOOST_USE_ITERATOR_ADAPTORS
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_USE_ITERATOR_ADAPTORS
|
||||
#include <boost/pending/iterator_adaptors.hpp>
|
||||
#else
|
||||
#include <boost/pending/detail/int_iterator.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
@ -24,29 +30,33 @@ namespace boost {
|
||||
//=============================================================================
|
||||
// Counting Iterator and Integer Range Class
|
||||
|
||||
#ifdef BOOST_USE_ITERATOR_ADAPTORS
|
||||
struct counting_iterator_policies : public default_iterator_policies
|
||||
{
|
||||
template <class IntegerType>
|
||||
IntegerType dereference(type<IntegerType>, const IntegerType& i) const
|
||||
const IntegerType&
|
||||
dereference(type<const IntegerType&>, const IntegerType& i) const
|
||||
{ return i; }
|
||||
};
|
||||
template <class IntegerType>
|
||||
struct counting_iterator_traits {
|
||||
typedef IntegerType value_type;
|
||||
typedef IntegerType reference;
|
||||
typedef const IntegerType& reference;
|
||||
typedef value_type* pointer;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
};
|
||||
#endif
|
||||
|
||||
template <class IntegerType>
|
||||
struct integer_range {
|
||||
#ifdef BOOST_MSVC
|
||||
typedef int_iterator<IntegerType> iterator;
|
||||
#else
|
||||
#ifdef BOOST_USE_ITERATOR_ADAPTORS
|
||||
typedef iterator_adaptor<IntegerType, counting_iterator_policies,
|
||||
counting_iterator_traits<IntegerType>, IntegerType> iterator;
|
||||
#else
|
||||
typedef int_iterator<IntegerType> iterator;
|
||||
#endif
|
||||
|
||||
typedef iterator const_iterator;
|
||||
typedef IntegerType value_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
@ -71,6 +81,17 @@ protected:
|
||||
IntegerType m_start, m_finish;
|
||||
};
|
||||
|
||||
template <class IntegerType>
|
||||
inline integer_range<IntegerType>
|
||||
make_integer_range(IntegerType first, IntegerType last)
|
||||
{
|
||||
return integer_range<IntegerType>(first, last);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#ifdef BOOST_USE_ITERATOR_ADAPTORS
|
||||
#undef BOOST_USE_ITERATOR_ADAPTORS
|
||||
#endif
|
||||
|
||||
#endif // BOOST_INTEGER_RANGE_HPP_
|
||||
|
@ -37,8 +37,11 @@ struct type {};
|
||||
// class if you want to customize particular policies.
|
||||
struct default_iterator_policies
|
||||
{
|
||||
// Some of these members were defined static, but Borland got confused
|
||||
// and thought they were non-const.
|
||||
|
||||
template <class Reference, class Iterator>
|
||||
static Reference dereference(type<Reference>, const Iterator& x)
|
||||
Reference dereference(type<Reference>, const Iterator& x) const
|
||||
{ return *x; }
|
||||
|
||||
template <class Iterator>
|
||||
@ -54,15 +57,15 @@ struct default_iterator_policies
|
||||
{ x += n; }
|
||||
|
||||
template <class Difference, class Iterator1, class Iterator2>
|
||||
static Difference distance(type<Difference>, const Iterator1& x, const Iterator2& y)
|
||||
Difference distance(type<Difference>, const Iterator1& x, const Iterator2& y) const
|
||||
{ return y - x; }
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
static bool equal(const Iterator1& x, const Iterator2& y)
|
||||
bool equal(const Iterator1& x, const Iterator2& y) const
|
||||
{ return x == y; }
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
static bool less(const Iterator1& x, const Iterator2& y)
|
||||
bool less(const Iterator1& x, const Iterator2& y) const
|
||||
{ return x < y; }
|
||||
};
|
||||
|
||||
@ -171,10 +174,11 @@ public:
|
||||
typedef typename Traits::pointer pointer;
|
||||
typedef typename Traits::reference reference;
|
||||
typedef typename Traits::iterator_category iterator_category;
|
||||
typedef Iterator iterator_type;
|
||||
|
||||
iterator_adaptor() { }
|
||||
|
||||
iterator_adaptor(const Iterator& iter, const Policies& p = Policies())
|
||||
iterator_adaptor(const iterator_type& iter, const Policies& p = Policies())
|
||||
: m_iter_p(iter, p) {}
|
||||
|
||||
#ifdef BOOST_MSVC6_MEMBER_TEMPLATES
|
||||
@ -223,7 +227,13 @@ public:
|
||||
{ return *(*this + n); }
|
||||
|
||||
Self& operator++() {
|
||||
#ifdef __MWERKS__
|
||||
// Odd bug, MWERKS couldn't deduce the type for the member template
|
||||
// Workaround by explicitly specifying the type.
|
||||
policies().increment<Iterator>(iter());
|
||||
#else
|
||||
policies().increment(iter());
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -246,6 +256,8 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
iterator_type base() const { return m_iter_p.first(); }
|
||||
|
||||
private:
|
||||
typedef Policies policies_type;
|
||||
compressed_pair<Iterator,Policies> m_iter_p;
|
||||
@ -475,7 +487,7 @@ struct reverse_iterator_policies
|
||||
|
||||
template <class Difference, class Iterator1, class Iterator2>
|
||||
Difference distance(type<Difference>, const Iterator1& x,
|
||||
const Iterator2& y) const
|
||||
const Iterator2& y) const
|
||||
{ return x - y; }
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
|
Reference in New Issue
Block a user