forked from boostorg/iterator
Removed Pointer template argument.
Made facade work with new categories only. Added old->new category conversion logic to adaptor. [SVN r1234]
This commit is contained in:
@@ -96,7 +96,6 @@ namespace detail
|
|||||||
, Incrementable // value_type
|
, Incrementable // value_type
|
||||||
, category
|
, category
|
||||||
, Incrementable const& // reference
|
, Incrementable const& // reference
|
||||||
, Incrementable const* // pointer
|
|
||||||
, difference
|
, difference
|
||||||
> type;
|
> type;
|
||||||
};
|
};
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
template <class Iter, class Value, class Category, class Reference, class Pointer, class Difference>
|
template <class Iter, class Value, class Category, class Reference, class Difference>
|
||||||
struct indirect_iterator;
|
struct indirect_iterator;
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
@@ -112,7 +112,7 @@ namespace boost
|
|||||||
|
|
||||||
// If the Value parameter is unspecified, we use this metafunction
|
// If the Value parameter is unspecified, we use this metafunction
|
||||||
// to deduce the default types
|
// to deduce the default types
|
||||||
template <class Iter, class Value, class Category, class Reference, class Pointer, class Difference>
|
template <class Iter, class Value, class Category, class Reference, class Difference>
|
||||||
struct indirect_base
|
struct indirect_base
|
||||||
{
|
{
|
||||||
typedef typename iterator_value<Iter>::type dereferenceable;
|
typedef typename iterator_value<Iter>::type dereferenceable;
|
||||||
@@ -138,18 +138,17 @@ namespace boost
|
|||||||
>::type cv_value_type;
|
>::type cv_value_type;
|
||||||
|
|
||||||
typedef iterator_adaptor<
|
typedef iterator_adaptor<
|
||||||
indirect_iterator<Iter, Value, Category, Reference, Pointer, Difference>
|
indirect_iterator<Iter, Value, Category, Reference, Difference>
|
||||||
, Iter
|
, Iter
|
||||||
, cv_value_type
|
, cv_value_type
|
||||||
, Category
|
, Category
|
||||||
, Reference
|
, Reference
|
||||||
, Pointer
|
|
||||||
, Difference
|
, Difference
|
||||||
> type;
|
> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct indirect_base<int, int, int, int, int, int> {};
|
struct indirect_base<int, int, int, int, int> {};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template <
|
template <
|
||||||
@@ -157,16 +156,15 @@ namespace boost
|
|||||||
, class Value = use_default
|
, class Value = use_default
|
||||||
, class Category = use_default
|
, class Category = use_default
|
||||||
, class Reference = use_default
|
, class Reference = use_default
|
||||||
, class Pointer = use_default
|
|
||||||
, class Difference = use_default
|
, class Difference = use_default
|
||||||
>
|
>
|
||||||
class indirect_iterator
|
class indirect_iterator
|
||||||
: public detail::indirect_base<
|
: public detail::indirect_base<
|
||||||
Iterator, Value, Category, Reference, Pointer, Difference
|
Iterator, Value, Category, Reference, Difference
|
||||||
>::type
|
>::type
|
||||||
{
|
{
|
||||||
typedef typename detail::indirect_base<
|
typedef typename detail::indirect_base<
|
||||||
Iterator, Value, Category, Reference, Pointer, Difference
|
Iterator, Value, Category, Reference, Difference
|
||||||
>::type super_t;
|
>::type super_t;
|
||||||
|
|
||||||
friend class iterator_core_access;
|
friend class iterator_core_access;
|
||||||
@@ -179,11 +177,11 @@ namespace boost
|
|||||||
|
|
||||||
template <
|
template <
|
||||||
class Iterator2, class Value2, class Category2
|
class Iterator2, class Value2, class Category2
|
||||||
, class Reference2, class Pointer2, class Difference2
|
, class Reference2, class Difference2
|
||||||
>
|
>
|
||||||
indirect_iterator(
|
indirect_iterator(
|
||||||
indirect_iterator<
|
indirect_iterator<
|
||||||
Iterator2, Value2, Category2, Reference2, Pointer2, Difference2
|
Iterator2, Value2, Category2, Reference2, Difference2
|
||||||
> const& y
|
> const& y
|
||||||
, typename enable_if_convertible<Iterator2, Iterator>::type* = 0
|
, typename enable_if_convertible<Iterator2, Iterator>::type* = 0
|
||||||
)
|
)
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include <boost/iterator.hpp>
|
#include <boost/iterator.hpp>
|
||||||
#include <boost/detail/iterator.hpp>
|
#include <boost/detail/iterator.hpp>
|
||||||
|
|
||||||
|
#include <boost/iterator/iterator_categories.hpp>
|
||||||
#include <boost/iterator/iterator_facade.hpp>
|
#include <boost/iterator/iterator_facade.hpp>
|
||||||
#include <boost/iterator/detail/enable_if.hpp>
|
#include <boost/iterator/detail/enable_if.hpp>
|
||||||
|
|
||||||
@@ -33,20 +34,6 @@ namespace boost
|
|||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template <class Traits, class Other>
|
|
||||||
struct same_category_and_difference
|
|
||||||
: mpl::and_<
|
|
||||||
is_same<
|
|
||||||
typename Traits::iterator_category
|
|
||||||
, typename Other::iterator_category
|
|
||||||
>
|
|
||||||
, is_same<
|
|
||||||
typename Traits::iterator_category // *** THIS IS A BUG!! ***
|
|
||||||
, typename Other::iterator_category // MAKE FAILING TEST BEFORE FIXING!!
|
|
||||||
>
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Result type used in enable_if_convertible meta function.
|
// Result type used in enable_if_convertible meta function.
|
||||||
@@ -187,17 +174,21 @@ namespace boost
|
|||||||
, class Value
|
, class Value
|
||||||
, class Category
|
, class Category
|
||||||
, class Reference
|
, class Reference
|
||||||
, class Pointer
|
|
||||||
, class Difference
|
, class Difference
|
||||||
>
|
>
|
||||||
struct iterator_adaptor_base
|
struct iterator_adaptor_base
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
typedef typename detail::ia_dflt_help<Category , mpl::true_ , BOOST_ITERATOR_CATEGORY<Base> >::type category;
|
||||||
|
typedef typename detail::ia_dflt_help<Reference , is_same<Value, use_default> , iterator_reference<Base> >::type reference;
|
||||||
|
|
||||||
|
public:
|
||||||
typedef iterator_facade<
|
typedef iterator_facade<
|
||||||
Derived
|
Derived
|
||||||
, typename detail::ia_dflt_help<Value , mpl::true_ , iterator_value<Base> >::type
|
, typename detail::ia_dflt_help<Value , mpl::true_ , iterator_value<Base> >::type
|
||||||
, typename detail::ia_dflt_help<Category , mpl::true_ , BOOST_ITERATOR_CATEGORY<Base> >::type
|
, typename access_category_tag< category, reference >::type
|
||||||
|
, typename traversal_category_tag< category >::type
|
||||||
, typename detail::ia_dflt_help<Reference , is_same<Value, use_default> , iterator_reference<Base> >::type
|
, typename detail::ia_dflt_help<Reference , is_same<Value, use_default> , iterator_reference<Base> >::type
|
||||||
, typename detail::ia_dflt_help<Pointer , is_same<Value, use_default> , iterator_pointer<Base> >::type
|
|
||||||
, typename detail::ia_dflt_help<Difference , mpl::true_ , iterator_difference<Base> >::type
|
, typename detail::ia_dflt_help<Difference , mpl::true_ , iterator_difference<Base> >::type
|
||||||
>
|
>
|
||||||
type;
|
type;
|
||||||
@@ -214,18 +205,17 @@ namespace boost
|
|||||||
, class Value = use_default
|
, class Value = use_default
|
||||||
, class Category = use_default
|
, class Category = use_default
|
||||||
, class Reference = use_default
|
, class Reference = use_default
|
||||||
, class Pointer = use_default
|
|
||||||
, class Difference = use_default
|
, class Difference = use_default
|
||||||
>
|
>
|
||||||
class iterator_adaptor
|
class iterator_adaptor
|
||||||
: public detail::iterator_adaptor_base<
|
: public detail::iterator_adaptor_base<
|
||||||
Derived, Base, Value, Category, Reference, Pointer, Difference
|
Derived, Base, Value, Category, Reference, Difference
|
||||||
>::type
|
>::type
|
||||||
{
|
{
|
||||||
friend class iterator_core_access;
|
friend class iterator_core_access;
|
||||||
|
|
||||||
typedef typename detail::iterator_adaptor_base<
|
typedef typename detail::iterator_adaptor_base<
|
||||||
Derived, Base, Value, Category, Reference, Pointer, Difference
|
Derived, Base, Value, Category, Reference, Difference
|
||||||
>::type super_t;
|
>::type super_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -260,13 +250,14 @@ namespace boost
|
|||||||
{ return *m_iterator; }
|
{ return *m_iterator; }
|
||||||
|
|
||||||
template <
|
template <
|
||||||
class OtherDerived, class OtherIterator, class V, class C, class R, class P, class D
|
class OtherDerived, class OtherIterator, class V, class C, class R, class D
|
||||||
>
|
>
|
||||||
bool equal(iterator_adaptor<OtherDerived, OtherIterator, V, C, R, P, D> const& x) const
|
bool equal(iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& x) const
|
||||||
{
|
{
|
||||||
BOOST_STATIC_ASSERT(
|
// Maybe readd with same_distance
|
||||||
(detail::same_category_and_difference<Derived,OtherDerived>::value)
|
// BOOST_STATIC_ASSERT(
|
||||||
);
|
// (detail::same_category_and_difference<Derived,OtherDerived>::value)
|
||||||
|
// );
|
||||||
return m_iterator == x.base();
|
return m_iterator == x.base();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,14 +270,15 @@ namespace boost
|
|||||||
void decrement() { --m_iterator; }
|
void decrement() { --m_iterator; }
|
||||||
|
|
||||||
template <
|
template <
|
||||||
class OtherDerived, class OtherIterator, class V, class C, class R, class P, class D
|
class OtherDerived, class OtherIterator, class V, class C, class R, class D
|
||||||
>
|
>
|
||||||
typename super_t::difference_type distance_to(
|
typename super_t::difference_type distance_to(
|
||||||
iterator_adaptor<OtherDerived, OtherIterator, V, C, R, P, D> const& y) const
|
iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& y) const
|
||||||
{
|
{
|
||||||
BOOST_STATIC_ASSERT(
|
// Maybe readd with same_distance
|
||||||
(detail::same_category_and_difference<Derived,OtherDerived>::value)
|
// BOOST_STATIC_ASSERT(
|
||||||
);
|
// (detail::same_category_and_difference<Derived,OtherDerived>::value)
|
||||||
|
// );
|
||||||
return y.base() - m_iterator;
|
return y.base() - m_iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -62,6 +62,13 @@ namespace boost
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<class Value, class AccessCategory>
|
||||||
|
struct const_qualified :
|
||||||
|
mpl::if_< is_tag< writable_iterator_tag, AccessCategory >,
|
||||||
|
Value,
|
||||||
|
Value const >
|
||||||
|
{};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Type generator.
|
// Type generator.
|
||||||
// Generates the corresponding std::iterator specialization
|
// Generates the corresponding std::iterator specialization
|
||||||
@@ -73,25 +80,21 @@ namespace boost
|
|||||||
// So use_default is its way to say what I really mean
|
// So use_default is its way to say what I really mean
|
||||||
// is youre default parameter.
|
// is youre default parameter.
|
||||||
//
|
//
|
||||||
template <class Value, class Category, class Reference, class Pointer, class Difference>
|
template <class Value, class AccessCategory, class TraversalCategory, class Reference, class Difference>
|
||||||
struct iterator_facade_base
|
struct iterator_facade_base
|
||||||
{
|
{
|
||||||
typedef iterator<
|
typedef iterator<
|
||||||
Category
|
iterator_tag<AccessCategory, TraversalCategory>
|
||||||
|
|
||||||
, typename remove_cv<Value>::type
|
, typename remove_cv<Value>::type
|
||||||
|
|
||||||
, Difference
|
, Difference
|
||||||
|
|
||||||
, typename mpl::if_<
|
, typename const_qualified<Value, AccessCategory>::type*
|
||||||
is_same<Pointer, use_default>
|
|
||||||
, Value*
|
|
||||||
, Pointer
|
|
||||||
>::type
|
|
||||||
|
|
||||||
, typename mpl::if_<
|
, typename mpl::if_<
|
||||||
is_same<Reference, use_default>
|
is_same<Reference, use_default>
|
||||||
, Value&
|
, typename const_qualified<Value, AccessCategory>::type&
|
||||||
, Reference
|
, Reference
|
||||||
>::type
|
>::type
|
||||||
>
|
>
|
||||||
@@ -208,18 +211,18 @@ namespace boost
|
|||||||
// Macros which describe the declarations of binary operators
|
// Macros which describe the declarations of binary operators
|
||||||
# define BOOST_ITERATOR_FACADE_INTEROP_HEAD(prefix, op, result_type) \
|
# define BOOST_ITERATOR_FACADE_INTEROP_HEAD(prefix, op, result_type) \
|
||||||
template < \
|
template < \
|
||||||
class Derived1, class V1, class C1, class R1, class P1, class D1 \
|
class Derived1, class V1, class AC1, class TC1, class R1, class D1 \
|
||||||
, class Derived2, class V2, class C2, class R2, class P2, class D2 \
|
, class Derived2, class V2, class AC2, class TC2, class R2, class D2 \
|
||||||
> \
|
> \
|
||||||
prefix typename detail::enable_if_interoperable< \
|
prefix typename detail::enable_if_interoperable< \
|
||||||
Derived1, Derived2, result_type \
|
Derived1, Derived2, result_type \
|
||||||
>::type \
|
>::type \
|
||||||
operator op( \
|
operator op( \
|
||||||
iterator_facade<Derived1, V1, C1, R1, P1, D1> const& lhs \
|
iterator_facade<Derived1, V1, AC1, TC1, R1, D1> const& lhs \
|
||||||
, iterator_facade<Derived2, V2, C2, R2, P2, D2> const& rhs)
|
, iterator_facade<Derived2, V2, AC2, TC2, R2, D2> const& rhs)
|
||||||
|
|
||||||
# define BOOST_ITERATOR_FACADE_PLUS_HEAD(prefix,args) \
|
# define BOOST_ITERATOR_FACADE_PLUS_HEAD(prefix,args) \
|
||||||
template <class Derived, class V, class C, class R, class P, class D> \
|
template <class Derived, class V, class AC, class TC, class R, class D> \
|
||||||
prefix Derived operator+ args
|
prefix Derived operator+ args
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -240,7 +243,7 @@ namespace boost
|
|||||||
public:
|
public:
|
||||||
# else
|
# else
|
||||||
|
|
||||||
template <class I, class V, class C, class R, class P, class D> friend class iterator_facade;
|
template <class I, class V, class AC, class TC, class R, class D> friend class iterator_facade;
|
||||||
|
|
||||||
# define BOOST_ITERATOR_FACADE_RELATION(op) \
|
# define BOOST_ITERATOR_FACADE_RELATION(op) \
|
||||||
BOOST_ITERATOR_FACADE_INTEROP_HEAD(friend,op, bool);
|
BOOST_ITERATOR_FACADE_INTEROP_HEAD(friend,op, bool);
|
||||||
@@ -260,7 +263,7 @@ namespace boost
|
|||||||
|
|
||||||
BOOST_ITERATOR_FACADE_PLUS_HEAD(
|
BOOST_ITERATOR_FACADE_PLUS_HEAD(
|
||||||
friend
|
friend
|
||||||
, (iterator_facade<Derived, V, C, R, P, D> const&
|
, (iterator_facade<Derived, V, AC, TC, R, D> const&
|
||||||
, typename Derived::difference_type)
|
, typename Derived::difference_type)
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
@@ -268,7 +271,7 @@ namespace boost
|
|||||||
BOOST_ITERATOR_FACADE_PLUS_HEAD(
|
BOOST_ITERATOR_FACADE_PLUS_HEAD(
|
||||||
friend
|
friend
|
||||||
, (typename Derived::difference_type
|
, (typename Derived::difference_type
|
||||||
, iterator_facade<Derived, V, C, R, P, D> const&)
|
, iterator_facade<Derived, V, AC, TC, R, D> const&)
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -326,19 +329,17 @@ namespace boost
|
|||||||
template <
|
template <
|
||||||
class Derived
|
class Derived
|
||||||
, class Value
|
, class Value
|
||||||
, class Category
|
, class AccessCategory
|
||||||
, class Reference = Value&
|
, class TraversalCategory
|
||||||
, class Pointer = Value*
|
, class Reference = typename detail::const_qualified<Value, AccessCategory>::type&
|
||||||
, class Difference = std::ptrdiff_t
|
, class Difference = std::ptrdiff_t
|
||||||
>
|
>
|
||||||
class iterator_facade
|
class iterator_facade
|
||||||
: public detail::iterator_facade_base<Value, Category, Reference, Pointer, Difference>::type
|
: public detail::iterator_facade_base<Value, AccessCategory, TraversalCategory, Reference, Difference>::type
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef iterator_facade<Derived, Value, Category, Reference, Pointer, Difference> self_t;
|
|
||||||
|
|
||||||
typedef typename
|
typedef typename
|
||||||
detail::iterator_facade_base<Value, Category, Reference, Pointer, Difference>::type
|
detail::iterator_facade_base<Value, AccessCategory, TraversalCategory, Reference, Difference>::type
|
||||||
super_t;
|
super_t;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -561,13 +562,13 @@ namespace boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOST_ITERATOR_FACADE_PLUS((
|
BOOST_ITERATOR_FACADE_PLUS((
|
||||||
iterator_facade<Derived, V, C, R, P, D> const& i
|
iterator_facade<Derived, V, AC, TC, R, D> const& i
|
||||||
, typename Derived::difference_type n
|
, typename Derived::difference_type n
|
||||||
))
|
))
|
||||||
|
|
||||||
BOOST_ITERATOR_FACADE_PLUS((
|
BOOST_ITERATOR_FACADE_PLUS((
|
||||||
typename Derived::difference_type n
|
typename Derived::difference_type n
|
||||||
, iterator_facade<Derived, V, C, R, P, D> const& i
|
, iterator_facade<Derived, V, AC, TC, R, D> const& i
|
||||||
))
|
))
|
||||||
# undef BOOST_ITERATOR_FACADE_PLUS
|
# undef BOOST_ITERATOR_FACADE_PLUS
|
||||||
# undef BOOST_ITERATOR_FACADE_PLUS_HEAD
|
# undef BOOST_ITERATOR_FACADE_PLUS_HEAD
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
template <class AdaptableUnaryFunction, class Iterator>
|
template <class UnaryFunction, class Iterator, class Reference = use_default, class Value = use_default>
|
||||||
class transform_iterator;
|
class transform_iterator;
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
@@ -27,7 +27,7 @@ namespace boost
|
|||||||
|
|
||||||
// Given the transform iterator's transformation and iterator, this
|
// Given the transform iterator's transformation and iterator, this
|
||||||
// is the type used as its traits.
|
// is the type used as its traits.
|
||||||
template <class UnaryFunction, class Iterator>
|
template <class UnaryFunction, class Iterator, class Reference, class Value>
|
||||||
struct transform_iterator_base
|
struct transform_iterator_base
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -71,12 +71,12 @@ namespace boost
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class AdaptableUnaryFunction, class Iterator>
|
template <class UnaryFunction, class Iterator, class Reference, class Value>
|
||||||
class transform_iterator
|
class transform_iterator
|
||||||
: public detail::transform_iterator_base<AdaptableUnaryFunction, Iterator>::type
|
: public detail::transform_iterator_base<UnaryFunction, Iterator, Reference, Value>::type
|
||||||
{
|
{
|
||||||
typedef typename
|
typedef typename
|
||||||
detail::transform_iterator_base<AdaptableUnaryFunction, Iterator>::type
|
detail::transform_iterator_base<UnaryFunction, Iterator, Reference, Value>::type
|
||||||
super_t;
|
super_t;
|
||||||
|
|
||||||
friend class iterator_core_access;
|
friend class iterator_core_access;
|
||||||
@@ -84,17 +84,17 @@ namespace boost
|
|||||||
public:
|
public:
|
||||||
transform_iterator() { }
|
transform_iterator() { }
|
||||||
|
|
||||||
transform_iterator(Iterator const& x, AdaptableUnaryFunction f)
|
transform_iterator(Iterator const& x, UnaryFunction f)
|
||||||
: super_t(x), m_f(f) { }
|
: super_t(x), m_f(f) { }
|
||||||
|
|
||||||
template<class OtherIterator>
|
template<class OtherIterator>
|
||||||
transform_iterator(
|
transform_iterator(
|
||||||
transform_iterator<AdaptableUnaryFunction, OtherIterator> const& t
|
transform_iterator<UnaryFunction, OtherIterator> const& t
|
||||||
, typename enable_if_convertible<OtherIterator, Iterator>::type* = 0
|
, typename enable_if_convertible<OtherIterator, Iterator>::type* = 0
|
||||||
)
|
)
|
||||||
: super_t(t.base()), m_f(t.functor()) {}
|
: super_t(t.base()), m_f(t.functor()) {}
|
||||||
|
|
||||||
AdaptableUnaryFunction functor() const
|
UnaryFunction functor() const
|
||||||
{ return m_f; }
|
{ return m_f; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -103,7 +103,7 @@ namespace boost
|
|||||||
|
|
||||||
// Probably should be the initial base class so it can be
|
// Probably should be the initial base class so it can be
|
||||||
// optimized away via EBO if it is an empty class.
|
// optimized away via EBO if it is an empty class.
|
||||||
AdaptableUnaryFunction m_f;
|
UnaryFunction m_f;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class UnaryFunction, class Iterator>
|
template <class UnaryFunction, class Iterator>
|
||||||
|
Reference in New Issue
Block a user