mirror of
https://github.com/boostorg/iterator.git
synced 2025-07-30 04:47:20 +02:00
Begun simplification
[SVN r20165]
This commit is contained in:
@ -39,40 +39,12 @@ namespace boost
|
|||||||
//
|
//
|
||||||
// Access Categories
|
// Access Categories
|
||||||
//
|
//
|
||||||
struct readable_iterator_tag
|
enum iterator_access
|
||||||
{
|
{
|
||||||
typedef std::input_iterator_tag max_category;
|
readable_iterator = 1
|
||||||
};
|
, writable_iterator = 2
|
||||||
|
, swappable_iterator = 4
|
||||||
struct writable_iterator_tag
|
, lvalue_iterator = 8
|
||||||
{
|
|
||||||
typedef std::output_iterator_tag max_category;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct swappable_iterator_tag
|
|
||||||
{
|
|
||||||
typedef detail::null_category_tag max_category;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct readable_writable_iterator_tag
|
|
||||||
: virtual readable_iterator_tag
|
|
||||||
, virtual writable_iterator_tag
|
|
||||||
, virtual swappable_iterator_tag
|
|
||||||
{
|
|
||||||
typedef detail::input_output_iterator_tag max_category;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct readable_lvalue_iterator_tag
|
|
||||||
: virtual readable_iterator_tag
|
|
||||||
{
|
|
||||||
typedef std::random_access_iterator_tag max_category;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct writable_lvalue_iterator_tag
|
|
||||||
: virtual public readable_writable_iterator_tag
|
|
||||||
, virtual public readable_lvalue_iterator_tag
|
|
||||||
{
|
|
||||||
typedef std::random_access_iterator_tag max_category;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -111,6 +83,11 @@ namespace boost
|
|||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
template <unsigned access>
|
||||||
|
access_c : mpl::integral_c<iterator_access,access>
|
||||||
|
{};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Tag detection meta functions
|
// Tag detection meta functions
|
||||||
//
|
//
|
||||||
@ -147,7 +124,7 @@ namespace boost
|
|||||||
// iterators which don't have an actual old-style category. We
|
// iterators which don't have an actual old-style category. We
|
||||||
// need that so there is a valid base class for all new-style
|
// need that so there is a valid base class for all new-style
|
||||||
// iterators.
|
// iterators.
|
||||||
# define BOOST_OLD_ITERATOR_CATEGORY(category) \
|
# define BOOST_OLD_ITERATOR_CATEGORY(category) \
|
||||||
template <> \
|
template <> \
|
||||||
struct is_tag <detail::null_category_tag, std::category> \
|
struct is_tag <detail::null_category_tag, std::category> \
|
||||||
: mpl::true_ {};
|
: mpl::true_ {};
|
||||||
|
@ -153,10 +153,8 @@ namespace boost
|
|||||||
typedef typename mpl::apply_if<
|
typedef typename mpl::apply_if<
|
||||||
mpl::or_<
|
mpl::or_<
|
||||||
is_same<Category, use_default>
|
is_same<Category, use_default>
|
||||||
, mpl::or_<
|
, is_access_tag<Category>
|
||||||
is_access_tag<Category>
|
, is_traversal_tag<Category>
|
||||||
, is_traversal_tag<Category>
|
|
||||||
>
|
|
||||||
>
|
>
|
||||||
, BOOST_ITERATOR_CATEGORY<Base>
|
, BOOST_ITERATOR_CATEGORY<Base>
|
||||||
, mpl::identity<Category>
|
, mpl::identity<Category>
|
||||||
|
@ -105,7 +105,7 @@ namespace boost {
|
|||||||
|
|
||||||
template <class Reference>
|
template <class Reference>
|
||||||
struct apply
|
struct apply
|
||||||
: mpl::identity<readable_iterator_tag> {};
|
: access_c<readable_iterator> {};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ namespace boost {
|
|||||||
|
|
||||||
template <class Reference>
|
template <class Reference>
|
||||||
struct apply
|
struct apply
|
||||||
: mpl::identity<writable_iterator_tag> {};
|
: access_c<writable_iterator> {};
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -128,8 +128,8 @@ namespace boost {
|
|||||||
struct apply
|
struct apply
|
||||||
: mpl::if_<
|
: mpl::if_<
|
||||||
python::detail::is_reference_to_const<Reference>
|
python::detail::is_reference_to_const<Reference>
|
||||||
, boost::readable_lvalue_iterator_tag
|
, access_c<(readable_iterator|lvalue_iterator)>
|
||||||
, boost::writable_lvalue_iterator_tag
|
, access_c<(readable_iterator|writable_iterator|lvalue_iterator)>
|
||||||
>
|
>
|
||||||
{};
|
{};
|
||||||
};
|
};
|
||||||
@ -151,30 +151,31 @@ namespace boost {
|
|||||||
template <class Category>
|
template <class Category>
|
||||||
struct old_tag_converter
|
struct old_tag_converter
|
||||||
: std_to_new_tags<
|
: std_to_new_tags<
|
||||||
|
// Take the category down to its most-refined known
|
||||||
|
// std::tag, in case of derivation/convertibility
|
||||||
typename std_category<Category>::type
|
typename std_category<Category>::type
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Category>
|
|
||||||
struct iter_category_to_traversal
|
|
||||||
: std_to_new_tags<
|
|
||||||
typename std_category<Category>::type
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
|
|
||||||
|
template <class OldTag>
|
||||||
|
struct old_tag_to_traversal
|
||||||
|
: old_tag_converter<OldTag>
|
||||||
|
{};
|
||||||
|
|
||||||
|
|
||||||
template <typename Category, typename Reference>
|
template <typename Category, typename Reference>
|
||||||
struct iter_category_to_access
|
struct old_tag_to_access
|
||||||
: mpl::apply1<
|
: mpl::apply1<
|
||||||
iter_category_to_traversal<Category>
|
old_tag_converter<Category>
|
||||||
, Reference
|
, Reference
|
||||||
>
|
>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
|
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
|
||||||
// Deal with ETI
|
// Deal with ETI
|
||||||
template <> struct iter_category_to_access<int, int> {};
|
template <> struct old_tag_to_access<int, int> {};
|
||||||
template <> struct iter_category_to_traversal<int> {};
|
template <> struct old_tag_converter<int> {};
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// A metafunction returning true iff T is boost::iterator_tag<R,U>
|
// A metafunction returning true iff T is boost::iterator_tag<R,U>
|
||||||
@ -231,71 +232,49 @@ namespace boost {
|
|||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template <class NewCategoryTag>
|
template <class NewCategoryTag>
|
||||||
struct get_traversal_category {
|
struct new_tag_to_traversal
|
||||||
typedef typename NewCategoryTag::traversal type;
|
{
|
||||||
|
typedef typename NewCategoryTag::traversal type;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Remove all writability from the given access tag. This
|
|
||||||
// functionality is part of new_category_to_access in order to
|
|
||||||
// support deduction of the proper default access category for
|
|
||||||
// iterator_adaptor; when the reference type is a reference to
|
|
||||||
// constant we must strip writability.
|
|
||||||
template <class AccessTag>
|
|
||||||
struct remove_access_writability
|
|
||||||
: mpl::apply_if<
|
|
||||||
is_tag<writable_lvalue_iterator_tag, AccessTag>
|
|
||||||
, mpl::identity<readable_lvalue_iterator_tag>
|
|
||||||
|
|
||||||
, mpl::apply_if<
|
|
||||||
is_tag<readable_writable_iterator_tag, AccessTag>
|
|
||||||
, mpl::identity<readable_iterator_tag>
|
|
||||||
|
|
||||||
, mpl::if_<
|
|
||||||
is_tag<writable_iterator_tag, AccessTag>
|
|
||||||
// Is this OK? I think it may correct be for all
|
|
||||||
// legitimate cases, because at this point the
|
|
||||||
// iterator is not readable, so it could not have
|
|
||||||
// been any more than writable + swappable.
|
|
||||||
, swappable_iterator_tag
|
|
||||||
, AccessTag
|
|
||||||
>
|
|
||||||
>
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
|
|
||||||
template <class NewCategoryTag, class Reference>
|
template <class NewCategoryTag, class Reference>
|
||||||
struct new_category_to_access
|
struct new_tag_to_access
|
||||||
|
{
|
||||||
|
typedef typename NewCategoryTag::access_type type;
|
||||||
|
}
|
||||||
|
#if 0 // what was this all about?
|
||||||
: mpl::apply_if<
|
: mpl::apply_if<
|
||||||
python::detail::is_reference_to_const<Reference>
|
python::detail::is_reference_to_const<Reference>
|
||||||
, remove_access_writability<typename NewCategoryTag::access>
|
, remove_access_writability<typename NewCategoryTag::access>
|
||||||
, mpl::identity<typename NewCategoryTag::access>
|
, mpl::identity<typename NewCategoryTag::access>
|
||||||
>
|
>
|
||||||
{};
|
{};
|
||||||
|
#endif
|
||||||
|
|
||||||
template <class CategoryTag, class Reference>
|
template <class CategoryTag, class Reference>
|
||||||
struct access_category_tag
|
struct tag_access_category
|
||||||
: mpl::apply_if<
|
: mpl::apply_if<
|
||||||
is_new_iterator_tag<CategoryTag>
|
is_new_iterator_tag<CategoryTag>
|
||||||
, new_category_to_access<CategoryTag, Reference>
|
, new_tag_to_access<CategoryTag>
|
||||||
, iter_category_to_access<CategoryTag, Reference>
|
, old_tag_to_access<CategoryTag, Reference>
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class CategoryTag>
|
template <class CategoryTag>
|
||||||
struct traversal_category_tag
|
struct tag_traversal_category
|
||||||
: mpl::apply_if<
|
: mpl::apply_if<
|
||||||
is_new_iterator_tag<CategoryTag>
|
is_new_iterator_tag<CategoryTag>
|
||||||
, get_traversal_category<CategoryTag>
|
, new_tag_to_traversal<CategoryTag>
|
||||||
, iter_category_to_traversal<CategoryTag>
|
, old_tag_to_traversal<CategoryTag>
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
|
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
|
||||||
// Deal with ETI
|
// Deal with ETI
|
||||||
template <> struct access_category_tag<int, int> { typedef void type; };
|
template <> struct tag_access_category<int, int> { typedef void type; };
|
||||||
template <> struct traversal_category_tag<int> { typedef void type; };
|
template <> struct tag_traversal_category<int> { typedef void type; };
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// iterator_tag_base - a metafunction to compute the appropriate
|
// iterator_tag_base - a metafunction to compute the appropriate
|
||||||
@ -330,14 +309,15 @@ namespace boost {
|
|||||||
|
|
||||||
template <class Iterator>
|
template <class Iterator>
|
||||||
struct access_category
|
struct access_category
|
||||||
: detail::access_category_tag<
|
: detail::tag_access_category<
|
||||||
typename detail::iterator_traits<Iterator>::iterator_category
|
typename detail::iterator_traits<Iterator>::iterator_category
|
||||||
, typename detail::iterator_traits<Iterator>::reference>
|
, typename detail::iterator_traits<Iterator>::reference
|
||||||
|
>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
template <class Iterator>
|
template <class Iterator>
|
||||||
struct traversal_category
|
struct traversal_category
|
||||||
: detail::traversal_category_tag<
|
: detail::tag_traversal_category<
|
||||||
typename detail::iterator_traits<Iterator>::iterator_category
|
typename detail::iterator_traits<Iterator>::iterator_category
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
@ -349,7 +329,7 @@ namespace boost {
|
|||||||
// requires instantiating iterator_traits on the
|
// requires instantiating iterator_traits on the
|
||||||
// placeholder. Instead we just specialize it as a metafunction
|
// placeholder. Instead we just specialize it as a metafunction
|
||||||
// class.
|
// class.
|
||||||
template <>
|
template <>
|
||||||
struct access_category<mpl::_1>
|
struct access_category<mpl::_1>
|
||||||
{
|
{
|
||||||
template <class T>
|
template <class T>
|
||||||
@ -370,10 +350,11 @@ template <>
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct access_category<T*>
|
struct access_category<T*>
|
||||||
: mpl::if_<
|
: mpl::if_<
|
||||||
is_const<T>
|
is_const<T>
|
||||||
, readable_lvalue_iterator_tag
|
, detail::access_c<(readable_iterator|lvalue_iterator)>
|
||||||
, writable_lvalue_iterator_tag>
|
, detail::access_c<(readable_iterator|writable_iterator|lvalue_iterator)>
|
||||||
|
>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -385,15 +366,16 @@ template <>
|
|||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
template <class AccessTag, class TraversalTag>
|
template <unsigned Access, class TraversalTag>
|
||||||
struct iterator_tag
|
struct iterator_tag
|
||||||
: detail::iterator_tag_base<
|
: detail::iterator_tag_base<
|
||||||
typename detail::max_known_access_tag<AccessTag>::type
|
typename detail::max_known_access_tag<Access>::type
|
||||||
, typename detail::max_known_traversal_tag<TraversalTag>::type
|
, typename detail::max_known_traversal_tag<TraversalTag>::type
|
||||||
>::type
|
>::type
|
||||||
{
|
{
|
||||||
typedef AccessTag access;
|
typedef detail::access_c<(Access & ~lvalue_iterator)> access_type;
|
||||||
typedef TraversalTag traversal;
|
BOOST_STATIC_CONSTANT(iterator_access, access_type::value);
|
||||||
|
typedef TraversalTag traversal;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
|
@ -75,25 +75,6 @@ namespace boost
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Add const qualification for iterators which are not writable
|
|
||||||
//
|
|
||||||
template<class Value, class AccessCategory>
|
|
||||||
struct const_qualified_ref :
|
|
||||||
mpl::if_< is_tag< writable_iterator_tag, AccessCategory >,
|
|
||||||
Value&,
|
|
||||||
Value const& >
|
|
||||||
{};
|
|
||||||
|
|
||||||
// The apparent duplication here works around a Borland problem
|
|
||||||
template<class Value, class AccessCategory>
|
|
||||||
struct const_qualified_ptr :
|
|
||||||
mpl::if_< is_tag< writable_iterator_tag, AccessCategory >,
|
|
||||||
Value*,
|
|
||||||
Value const* >
|
|
||||||
{};
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Generates the associated types for an iterator_facade with the
|
// Generates the associated types for an iterator_facade with the
|
||||||
// given parameters. Additionally generates a 'base' type for
|
// given parameters. Additionally generates a 'base' type for
|
||||||
@ -104,7 +85,7 @@ namespace boost
|
|||||||
class Value
|
class Value
|
||||||
, class AccessCategory
|
, class AccessCategory
|
||||||
, class TraversalCategory
|
, class TraversalCategory
|
||||||
, class Reference
|
, class Reference
|
||||||
, class Difference
|
, class Difference
|
||||||
>
|
>
|
||||||
struct iterator_facade_types
|
struct iterator_facade_types
|
||||||
@ -117,17 +98,6 @@ namespace boost
|
|||||||
|
|
||||||
typedef typename const_qualified_ptr<Value, AccessCategory>::type pointer;
|
typedef typename const_qualified_ptr<Value, AccessCategory>::type pointer;
|
||||||
|
|
||||||
// The use_default support is needed for iterator_adaptor.
|
|
||||||
// For practical reasons iterator_adaptor needs to specify
|
|
||||||
// a fixed number of template arguments of iterator_facade.
|
|
||||||
// So use_default is its way to say: "What I really mean
|
|
||||||
// is your default parameter".
|
|
||||||
typedef typename mpl::if_<
|
|
||||||
is_same<Reference, use_default>
|
|
||||||
, typename const_qualified_ref<Value, AccessCategory>::type
|
|
||||||
, Reference
|
|
||||||
>::type reference;
|
|
||||||
|
|
||||||
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||||
&& (BOOST_WORKAROUND(_STLPORT_VERSION, BOOST_TESTED_AT(0x452)) \
|
&& (BOOST_WORKAROUND(_STLPORT_VERSION, BOOST_TESTED_AT(0x452)) \
|
||||||
|| BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, BOOST_TESTED_AT(310))) \
|
|| BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, BOOST_TESTED_AT(310))) \
|
||||||
@ -372,7 +342,7 @@ namespace boost
|
|||||||
, class Value
|
, class Value
|
||||||
, class AccessCategory
|
, class AccessCategory
|
||||||
, class TraversalCategory
|
, class TraversalCategory
|
||||||
, class Reference = BOOST_DEDUCED_TYPENAME detail::const_qualified_ref<Value, AccessCategory>::type
|
, class Reference = Value&
|
||||||
, class Difference = std::ptrdiff_t
|
, class Difference = std::ptrdiff_t
|
||||||
>
|
>
|
||||||
class iterator_facade
|
class iterator_facade
|
||||||
@ -384,10 +354,6 @@ namespace boost
|
|||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef typename
|
|
||||||
detail::iterator_facade_types<Value, AccessCategory, TraversalCategory, Reference, Difference>
|
|
||||||
types;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Curiously Recursive Template interface.
|
// Curiously Recursive Template interface.
|
||||||
//
|
//
|
||||||
@ -405,9 +371,9 @@ namespace boost
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef typename types::value_type value_type;
|
typedef typename remove_cv<Value> value_type;
|
||||||
typedef typename types::reference reference;
|
typedef typename Reference reference;
|
||||||
typedef typename types::difference_type difference_type;
|
typedef typename Difference difference_type;
|
||||||
typedef typename types::pointer pointer;
|
typedef typename types::pointer pointer;
|
||||||
typedef typename types::iterator_category iterator_category;
|
typedef typename types::iterator_category iterator_category;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user