forked from boostorg/iterator
removed less() function from policies
policies now operate on whole adaptors rather than Base types [SVN r11377]
This commit is contained in:
@ -135,7 +135,15 @@ namespace detail {
|
|||||||
// For a while, this wasn't true, but we rely on it below. This is a regression assert.
|
// For a while, this wasn't true, but we rely on it below. This is a regression assert.
|
||||||
BOOST_STATIC_ASSERT(::boost::is_integral<char>::value);
|
BOOST_STATIC_ASSERT(::boost::is_integral<char>::value);
|
||||||
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||||
BOOST_STATIC_CONSTANT(bool, value = std::numeric_limits<T>::is_specialized);
|
# if defined(ULLONG_MAX) || defined(ULONG_LONG_MAX)
|
||||||
|
BOOST_STATIC_CONSTANT(bool,
|
||||||
|
value = (
|
||||||
|
std::numeric_limits<T>::is_specialized
|
||||||
|
| boost::is_same<T,long long>::value
|
||||||
|
| boost::is_same<T,unsigned long long>::value));
|
||||||
|
# else
|
||||||
|
BOOST_STATIC_CONSTANT(bool, value = std::numeric_limits<T>::is_specialized);
|
||||||
|
# endif
|
||||||
# else
|
# else
|
||||||
# if !defined(__BORLANDC__)
|
# if !defined(__BORLANDC__)
|
||||||
BOOST_STATIC_CONSTANT(bool, value = (
|
BOOST_STATIC_CONSTANT(bool, value = (
|
||||||
@ -173,14 +181,17 @@ struct counting_iterator_traits {
|
|||||||
template <class Incrementable>
|
template <class Incrementable>
|
||||||
struct counting_iterator_policies : public default_iterator_policies
|
struct counting_iterator_policies : public default_iterator_policies
|
||||||
{
|
{
|
||||||
const Incrementable& dereference(type<const Incrementable&>, const Incrementable& i) const
|
template <class IteratorAdaptor>
|
||||||
{ return i; }
|
typename IteratorAdaptor::reference dereference(const IteratorAdaptor& i) const
|
||||||
|
{ return i.base(); }
|
||||||
template <class Difference, class Iterator1, class Iterator2>
|
|
||||||
Difference distance(type<Difference>, const Iterator1& x,
|
template <class Iterator1, class Iterator2>
|
||||||
const Iterator2& y) const
|
typename Iterator1::difference_type distance(
|
||||||
|
const Iterator1& x, const Iterator2& y) const
|
||||||
{
|
{
|
||||||
return boost::detail::any_distance<Difference>(x, y);//,(Difference*)());
|
typedef typename Iterator1::difference_type difference_type;
|
||||||
|
return boost::detail::any_distance<difference_type>(
|
||||||
|
x.base(), y.base());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ struct TrivialIteratorPoliciesConcept
|
|||||||
const_constraints();
|
const_constraints();
|
||||||
}
|
}
|
||||||
void const_constraints() const {
|
void const_constraints() const {
|
||||||
Reference r = p.dereference(type<Reference>(), x);
|
Reference r = p.dereference(x);
|
||||||
b = p.equal(x, x);
|
b = p.equal(x, x);
|
||||||
ignore_unused_variable_warning(r);
|
ignore_unused_variable_warning(r);
|
||||||
}
|
}
|
||||||
@ -208,8 +208,7 @@ struct RandomAccessIteratorPoliciesConcept
|
|||||||
ignore_unused_variable_warning(t);
|
ignore_unused_variable_warning(t);
|
||||||
}
|
}
|
||||||
void const_constraints() const {
|
void const_constraints() const {
|
||||||
n = p.distance(type<DifferenceType>(), x, x);
|
n = p.distance(x, x);
|
||||||
b = p.less(x, x);
|
|
||||||
}
|
}
|
||||||
Policies p;
|
Policies p;
|
||||||
Adapted x;
|
Adapted x;
|
||||||
@ -231,37 +230,30 @@ struct default_iterator_policies
|
|||||||
void initialize(Base&)
|
void initialize(Base&)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
// The "type<Reference>" parameter is a portable mechanism for
|
template <class IteratorAdaptor>
|
||||||
// the iterator_adaptor class to tell this member function what
|
typename IteratorAdaptor::reference dereference(const IteratorAdaptor& x) const
|
||||||
// the Reference type is, which is needed for the return type.
|
{ return *x.base(); }
|
||||||
template <class Reference, class Base>
|
|
||||||
Reference dereference(type<Reference>, const Base& x) const
|
|
||||||
{ return *x; }
|
|
||||||
|
|
||||||
template <class Base>
|
template <class IteratorAdaptor>
|
||||||
void increment(Base& x)
|
void increment(IteratorAdaptor& x)
|
||||||
{ ++x; }
|
{ ++x.base(); }
|
||||||
|
|
||||||
template <class Base>
|
template <class IteratorAdaptor>
|
||||||
void decrement(Base& x)
|
void decrement(IteratorAdaptor& x)
|
||||||
{ --x; }
|
{ --x.base(); }
|
||||||
|
|
||||||
template <class Base, class DifferenceType>
|
template <class IteratorAdaptor, class DifferenceType>
|
||||||
void advance(Base& x, DifferenceType n)
|
void advance(IteratorAdaptor& x, DifferenceType n)
|
||||||
{ x += n; }
|
{ x.base() += n; }
|
||||||
|
|
||||||
template <class Difference, class Iterator1, class Iterator2>
|
template <class IteratorAdaptor1, class IteratorAdaptor2>
|
||||||
Difference distance(type<Difference>, const Iterator1& x,
|
typename IteratorAdaptor1::difference_type
|
||||||
const Iterator2& y) const
|
distance(const IteratorAdaptor1& x, const IteratorAdaptor2& y) const
|
||||||
{ return y - x; }
|
{ return y.base() - x.base(); }
|
||||||
|
|
||||||
template <class Iterator1, class Iterator2>
|
template <class IteratorAdaptor1, class IteratorAdaptor2>
|
||||||
bool equal(const Iterator1& x, const Iterator2& y) const
|
bool equal(const IteratorAdaptor1& x, const IteratorAdaptor2& y) const
|
||||||
{ return x == y; }
|
{ return x.base() == y.base(); }
|
||||||
|
|
||||||
template <class Iterator1, class Iterator2>
|
|
||||||
bool less(const Iterator1& x, const Iterator2& y) const
|
|
||||||
{ return x < y; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// putting the comparisons in a base class avoids the g++
|
// putting the comparisons in a base class avoids the g++
|
||||||
@ -277,7 +269,7 @@ inline bool operator==(const iterator_comparisons<D1,Base1>& xb,
|
|||||||
{
|
{
|
||||||
const D1& x = static_cast<const D1&>(xb);
|
const D1& x = static_cast<const D1&>(xb);
|
||||||
const D2& y = static_cast<const D2&>(yb);
|
const D2& y = static_cast<const D2&>(yb);
|
||||||
return x.policies().equal(x.iter(), y.iter());
|
return x.policies().equal(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class D1, class D2, class Base1, class Base2>
|
template <class D1, class D2, class Base1, class Base2>
|
||||||
@ -286,7 +278,7 @@ inline bool operator!=(const iterator_comparisons<D1,Base1>& xb,
|
|||||||
{
|
{
|
||||||
const D1& x = static_cast<const D1&>(xb);
|
const D1& x = static_cast<const D1&>(xb);
|
||||||
const D2& y = static_cast<const D2&>(yb);
|
const D2& y = static_cast<const D2&>(yb);
|
||||||
return !x.policies().equal(x.iter(), y.iter());
|
return !x.policies().equal(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class D1, class D2, class Base1, class Base2>
|
template <class D1, class D2, class Base1, class Base2>
|
||||||
@ -295,7 +287,7 @@ inline bool operator<(const iterator_comparisons<D1,Base1>& xb,
|
|||||||
{
|
{
|
||||||
const D1& x = static_cast<const D1&>(xb);
|
const D1& x = static_cast<const D1&>(xb);
|
||||||
const D2& y = static_cast<const D2&>(yb);
|
const D2& y = static_cast<const D2&>(yb);
|
||||||
return x.policies().less(x.iter(), y.iter());
|
return x.policies().distance(x, y) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class D1, class D2, class Base1, class Base2>
|
template <class D1, class D2, class Base1, class Base2>
|
||||||
@ -304,7 +296,7 @@ inline bool operator>(const iterator_comparisons<D1,Base1>& xb,
|
|||||||
{
|
{
|
||||||
const D1& x = static_cast<const D1&>(xb);
|
const D1& x = static_cast<const D1&>(xb);
|
||||||
const D2& y = static_cast<const D2&>(yb);
|
const D2& y = static_cast<const D2&>(yb);
|
||||||
return x.policies().less(y.iter(), x.iter());
|
return x.policies().distance(y, x) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class D1, class D2, class Base1, class Base2>
|
template <class D1, class D2, class Base1, class Base2>
|
||||||
@ -313,7 +305,7 @@ inline bool operator>=(const iterator_comparisons<D1,Base1>& xb,
|
|||||||
{
|
{
|
||||||
const D1& x = static_cast<const D1&>(xb);
|
const D1& x = static_cast<const D1&>(xb);
|
||||||
const D2& y = static_cast<const D2&>(yb);
|
const D2& y = static_cast<const D2&>(yb);
|
||||||
return !x.policies().less(x.iter(), y.iter());
|
return !(x.policies().distance(x, y) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class D1, class D2, class Base1, class Base2>
|
template <class D1, class D2, class Base1, class Base2>
|
||||||
@ -322,7 +314,7 @@ inline bool operator<=(const iterator_comparisons<D1,Base1>& xb,
|
|||||||
{
|
{
|
||||||
const D1& x = static_cast<const D1&>(xb);
|
const D1& x = static_cast<const D1&>(xb);
|
||||||
const D2& y = static_cast<const D2&>(yb);
|
const D2& y = static_cast<const D2&>(yb);
|
||||||
return !x.policies().less(y.iter(), x.iter());
|
return !(x.policies().distance(y, x) > 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -641,15 +633,15 @@ struct iterator_adaptor :
|
|||||||
explicit
|
explicit
|
||||||
iterator_adaptor(const Base& it, const Policies& p = Policies())
|
iterator_adaptor(const Base& it, const Policies& p = Policies())
|
||||||
: m_iter_p(it, p) {
|
: m_iter_p(it, p) {
|
||||||
policies().initialize(iter());
|
policies().initialize(base());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Iter2, class Value2, class Pointer2, class Reference2>
|
template <class Iter2, class Value2, class Pointer2, class Reference2>
|
||||||
iterator_adaptor (
|
iterator_adaptor (
|
||||||
const iterator_adaptor<Iter2,Policies,Value2,Reference2,Pointer2,Category,Distance>& src)
|
const iterator_adaptor<Iter2,Policies,Value2,Reference2,Pointer2,Category,Distance>& src)
|
||||||
: m_iter_p(src.iter(), src.policies())
|
: m_iter_p(src.base(), src.policies())
|
||||||
{
|
{
|
||||||
policies().initialize(iter());
|
policies().initialize(base());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_MSVC) || defined(__BORLANDC__)
|
#if defined(BOOST_MSVC) || defined(__BORLANDC__)
|
||||||
@ -661,7 +653,7 @@ struct iterator_adaptor :
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
reference operator*() const {
|
reference operator*() const {
|
||||||
return policies().dereference(type<reference>(), iter());
|
return policies().dereference(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
@ -684,9 +676,9 @@ struct iterator_adaptor :
|
|||||||
#ifdef __MWERKS__
|
#ifdef __MWERKS__
|
||||||
// Odd bug, MWERKS couldn't deduce the type for the member template
|
// Odd bug, MWERKS couldn't deduce the type for the member template
|
||||||
// Workaround by explicitly specifying the type.
|
// Workaround by explicitly specifying the type.
|
||||||
policies().increment<Base>(iter());
|
policies().increment<self>(*this);
|
||||||
#else
|
#else
|
||||||
policies().increment(iter());
|
policies().increment(*this);
|
||||||
#endif
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -695,9 +687,9 @@ struct iterator_adaptor :
|
|||||||
|
|
||||||
self& operator--() {
|
self& operator--() {
|
||||||
#ifdef __MWERKS__
|
#ifdef __MWERKS__
|
||||||
policies().decrement<Base>(iter());
|
policies().decrement<self>(*this);
|
||||||
#else
|
#else
|
||||||
policies().decrement(iter());
|
policies().decrement(*this);
|
||||||
#endif
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -705,16 +697,16 @@ struct iterator_adaptor :
|
|||||||
self operator--(int) { self tmp(*this); --*this; return tmp; }
|
self operator--(int) { self tmp(*this); --*this; return tmp; }
|
||||||
|
|
||||||
self& operator+=(difference_type n) {
|
self& operator+=(difference_type n) {
|
||||||
policies().advance(iter(), n);
|
policies().advance(*this, n);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
self& operator-=(difference_type n) {
|
self& operator-=(difference_type n) {
|
||||||
policies().advance(iter(), -n);
|
policies().advance(*this, -n);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
base_type base() const { return m_iter_p.first(); }
|
base_type const& base() const { return m_iter_p.first(); }
|
||||||
|
|
||||||
// Moved from global scope to avoid ambiguity with the operator-() which
|
// Moved from global scope to avoid ambiguity with the operator-() which
|
||||||
// subtracts iterators from one another.
|
// subtracts iterators from one another.
|
||||||
@ -724,11 +716,9 @@ private:
|
|||||||
compressed_pair<Base,Policies> m_iter_p;
|
compressed_pair<Base,Policies> m_iter_p;
|
||||||
|
|
||||||
public: // implementation details (too many compilers have trouble when these are private).
|
public: // implementation details (too many compilers have trouble when these are private).
|
||||||
|
base_type& base() { return m_iter_p.first(); }
|
||||||
Policies& policies() { return m_iter_p.second(); }
|
Policies& policies() { return m_iter_p.second(); }
|
||||||
const Policies& policies() const { return m_iter_p.second(); }
|
const Policies& policies() const { return m_iter_p.second(); }
|
||||||
|
|
||||||
Base& iter() { return m_iter_p.first(); }
|
|
||||||
const Base& iter() const { return m_iter_p.first(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Base, class Policies, class Value, class Reference, class Pointer,
|
template <class Base, class Policies, class Value, class Reference, class Pointer,
|
||||||
@ -761,7 +751,7 @@ operator-(
|
|||||||
{
|
{
|
||||||
typedef typename iterator_adaptor<Iterator1,Policies,Value1,Reference1,
|
typedef typename iterator_adaptor<Iterator1,Policies,Value1,Reference1,
|
||||||
Pointer1,Category,Distance>::difference_type difference_type;
|
Pointer1,Category,Distance>::difference_type difference_type;
|
||||||
return x.policies().distance(type<difference_type>(), y.iter(), x.iter());
|
return x.policies().distance(y, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_RELOPS_AMBIGUITY_BUG
|
#ifndef BOOST_RELOPS_AMBIGUITY_BUG
|
||||||
@ -773,7 +763,7 @@ operator==(
|
|||||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||||
{
|
{
|
||||||
return x.policies().equal(x.iter(), y.iter());
|
return x.policies().equal(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||||
@ -784,7 +774,7 @@ operator<(
|
|||||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||||
{
|
{
|
||||||
return x.policies().less(x.iter(), y.iter());
|
return x.policies().distance(x, y) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||||
@ -795,7 +785,7 @@ operator>(
|
|||||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||||
{
|
{
|
||||||
return x.policies().less(y.iter(), x.iter());
|
return x.policies().distance(y, x) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||||
@ -806,7 +796,7 @@ operator>=(
|
|||||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||||
{
|
{
|
||||||
return !x.policies().less(x.iter(), y.iter());
|
return !(x.policies().distance(x, y) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||||
@ -817,7 +807,7 @@ operator<=(
|
|||||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||||
{
|
{
|
||||||
return !x.policies().less(y.iter(), x.iter());
|
return !(x.policies().distance(y, x) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||||
@ -828,7 +818,7 @@ operator!=(
|
|||||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||||
{
|
{
|
||||||
return !x.policies().equal(x.iter(), y.iter());
|
return !x.policies().equal(x, y);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -844,9 +834,10 @@ struct transform_iterator_policies : public default_iterator_policies
|
|||||||
transform_iterator_policies() { }
|
transform_iterator_policies() { }
|
||||||
transform_iterator_policies(const AdaptableUnaryFunction& f) : m_f(f) { }
|
transform_iterator_policies(const AdaptableUnaryFunction& f) : m_f(f) { }
|
||||||
|
|
||||||
template <class Reference, class Iterator>
|
template <class IteratorAdaptor>
|
||||||
Reference dereference(type<Reference>, const Iterator& iter) const
|
typename IteratorAdaptor::reference
|
||||||
{ return m_f(*iter); }
|
dereference(const IteratorAdaptor& iter) const
|
||||||
|
{ return m_f(*iter.base()); }
|
||||||
|
|
||||||
AdaptableUnaryFunction m_f;
|
AdaptableUnaryFunction m_f;
|
||||||
};
|
};
|
||||||
@ -889,9 +880,9 @@ make_transform_iterator(
|
|||||||
|
|
||||||
struct indirect_iterator_policies : public default_iterator_policies
|
struct indirect_iterator_policies : public default_iterator_policies
|
||||||
{
|
{
|
||||||
template <class Reference, class Iterator>
|
template <class IteratorAdaptor>
|
||||||
Reference dereference(type<Reference>, const Iterator& x) const
|
typename IteratorAdaptor::reference dereference(const IteratorAdaptor& x) const
|
||||||
{ return **x; }
|
{ return **x.base(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
@ -984,34 +975,30 @@ make_indirect_iterator(OuterIterator base)
|
|||||||
|
|
||||||
struct reverse_iterator_policies : public default_iterator_policies
|
struct reverse_iterator_policies : public default_iterator_policies
|
||||||
{
|
{
|
||||||
template <class Reference, class BidirectionalIterator>
|
template <class IteratorAdaptor>
|
||||||
Reference dereference(type<Reference>, const BidirectionalIterator& x) const
|
typename IteratorAdaptor::reference dereference(const IteratorAdaptor& x) const
|
||||||
{ return *boost::prior(x); }
|
{ return *boost::prior(x.base()); }
|
||||||
|
|
||||||
template <class BidirectionalIterator>
|
template <class BidirectionalIterator>
|
||||||
void increment(BidirectionalIterator& x) const
|
void increment(BidirectionalIterator& x) const
|
||||||
{ --x; }
|
{ --x.base(); }
|
||||||
|
|
||||||
template <class BidirectionalIterator>
|
template <class BidirectionalIterator>
|
||||||
void decrement(BidirectionalIterator& x) const
|
void decrement(BidirectionalIterator& x) const
|
||||||
{ ++x; }
|
{ ++x.base(); }
|
||||||
|
|
||||||
template <class BidirectionalIterator, class DifferenceType>
|
template <class BidirectionalIterator, class DifferenceType>
|
||||||
void advance(BidirectionalIterator& x, DifferenceType n) const
|
void advance(BidirectionalIterator& x, DifferenceType n) const
|
||||||
{ x -= n; }
|
{ x.base() -= n; }
|
||||||
|
|
||||||
template <class Difference, class Iterator1, class Iterator2>
|
template <class Iterator1, class Iterator2>
|
||||||
Difference distance(type<Difference>, const Iterator1& x,
|
typename Iterator1::difference_type distance(
|
||||||
const Iterator2& y) const
|
const Iterator1& x, const Iterator2& y) const
|
||||||
{ return x - y; }
|
{ return x.base() - y.base(); }
|
||||||
|
|
||||||
template <class Iterator1, class Iterator2>
|
template <class Iterator1, class Iterator2>
|
||||||
bool equal(const Iterator1& x, const Iterator2& y) const
|
bool equal(const Iterator1& x, const Iterator2& y) const
|
||||||
{ return x == y; }
|
{ return x.base() == y.base(); }
|
||||||
|
|
||||||
template <class Iterator1, class Iterator2>
|
|
||||||
bool less(const Iterator1& x, const Iterator2& y) const
|
|
||||||
{ return y < x; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class BidirectionalIterator,
|
template <class BidirectionalIterator,
|
||||||
@ -1044,9 +1031,9 @@ struct projection_iterator_policies : public default_iterator_policies
|
|||||||
projection_iterator_policies() { }
|
projection_iterator_policies() { }
|
||||||
projection_iterator_policies(const AdaptableUnaryFunction& f) : m_f(f) { }
|
projection_iterator_policies(const AdaptableUnaryFunction& f) : m_f(f) { }
|
||||||
|
|
||||||
template <class Reference, class Iterator>
|
template <class IteratorAdaptor>
|
||||||
Reference dereference (type<Reference>, Iterator const& iter) const {
|
typename IteratorAdaptor::reference dereference(IteratorAdaptor const& iter) const {
|
||||||
return m_f(*iter);
|
return m_f(*iter.base());
|
||||||
}
|
}
|
||||||
|
|
||||||
AdaptableUnaryFunction m_f;
|
AdaptableUnaryFunction m_f;
|
||||||
@ -1113,28 +1100,29 @@ public:
|
|||||||
|
|
||||||
// The Iter template argument is neccessary for compatibility with a MWCW
|
// The Iter template argument is neccessary for compatibility with a MWCW
|
||||||
// bug workaround
|
// bug workaround
|
||||||
template <class Iter>
|
template <class IteratorAdaptor>
|
||||||
void increment(Iter& x) {
|
void increment(IteratorAdaptor& x) {
|
||||||
++x;
|
++x.base();
|
||||||
satisfy_predicate(x);
|
satisfy_predicate(x.base());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Reference, class Iter>
|
template <class IteratorAdaptor>
|
||||||
Reference dereference(type<Reference>, const Iter& x) const
|
typename IteratorAdaptor::reference dereference(const IteratorAdaptor& x) const
|
||||||
{ return *x; }
|
{ return *x.base(); }
|
||||||
|
|
||||||
template <class Iterator1, class Iterator2>
|
template <class IteratorAdaptor1, class IteratorAdaptor2>
|
||||||
bool equal(const Iterator1& x, const Iterator2& y) const
|
bool equal(const IteratorAdaptor1& x, const IteratorAdaptor2& y) const
|
||||||
{ return x == y; }
|
{ return x.base() == y.base(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void satisfy_predicate(Iterator& iter);
|
void satisfy_predicate(Iterator& iter);
|
||||||
Predicate m_predicate;
|
Predicate m_predicate;
|
||||||
Iterator m_end;
|
Iterator m_end;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Predicate, class Iterator>
|
template <class Predicate, class Iterator>
|
||||||
void filter_iterator_policies<Predicate,Iterator>
|
void filter_iterator_policies<Predicate,Iterator>::satisfy_predicate(
|
||||||
::satisfy_predicate(Iterator& iter)
|
Iterator& iter)
|
||||||
{
|
{
|
||||||
while (m_end != iter && !m_predicate(*iter))
|
while (m_end != iter && !m_predicate(*iter))
|
||||||
++iter;
|
++iter;
|
||||||
|
Reference in New Issue
Block a user