123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- #ifndef BOOST_ITERATOR_ADAPTOR_23022003THW_HPP
- #define BOOST_ITERATOR_ADAPTOR_23022003THW_HPP
- #include <boost/static_assert.hpp>
- #include <boost/iterator.hpp>
- #include <boost/detail/iterator.hpp>
- #include <boost/iterator/iterator_categories.hpp>
- #include <boost/iterator/iterator_facade.hpp>
- #include <boost/iterator/detail/enable_if.hpp>
- #include <boost/mpl/and.hpp>
- #include <boost/mpl/not.hpp>
- #include <boost/mpl/or.hpp>
- #include <boost/type_traits/is_same.hpp>
- #include <boost/type_traits/is_convertible.hpp>
- #ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY
- # include <boost/type_traits/remove_reference.hpp>
- # if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x610))
- # include <boost/type_traits/add_reference.hpp>
- # endif
- #else
- # include <boost/type_traits/add_reference.hpp>
- #endif
- #include <boost/iterator/detail/config_def.hpp>
- #include <boost/iterator/iterator_traits.hpp>
- namespace boost
- {
-
-
-
- struct use_default;
-
- # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
-
-
-
- template<class To>
- struct is_convertible<use_default,To>
- : mpl::false_ {};
- # endif
-
- namespace detail
- {
-
-
-
-
-
-
-
- struct enable_type;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
-
- template<typename From, typename To>
- struct enable_if_convertible
- {
- typedef typename mpl::if_<
- mpl::or_<
- is_same<From,To>
- , is_convertible<From, To>
- >
- , boost::detail::enable_type
- , int&
- >::type type;
- };
-
- # elif defined(BOOST_NO_IS_CONVERTIBLE) || defined(BOOST_NO_SFINAE)
-
- template <class From, class To>
- struct enable_if_convertible
- {
- typedef boost::detail::enable_type type;
- };
-
- # elif BOOST_WORKAROUND(_MSC_FULL_VER, BOOST_TESTED_AT(13102292)) && BOOST_MSVC > 1300
-
-
-
- template<typename From, typename To>
- struct enable_if_convertible
- : iterators::enable_if<
- mpl::or_<
- is_same<From,To>
- , is_convertible<From, To>
- >
- , boost::detail::enable_type
- >
- {};
-
- # else
-
- template<typename From, typename To>
- struct enable_if_convertible
- : iterators::enable_if<
- is_convertible<From, To>
- , boost::detail::enable_type
- >
- {};
-
- # endif
-
-
-
-
- namespace detail
- {
-
-
- template <class T, class DefaultNullaryFn>
- struct ia_dflt_help
- : mpl::eval_if<
- is_same<T, use_default>
- , DefaultNullaryFn
- , mpl::identity<T>
- >
- {
- };
-
-
- template <
- class Derived
- , class Base
- , class Value
- , class Traversal
- , class Reference
- , class Difference
- >
- struct iterator_adaptor_base
- {
- typedef iterator_facade<
- Derived
-
- # ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY
- , typename boost::detail::ia_dflt_help<
- Value
- , mpl::eval_if<
- is_same<Reference,use_default>
- , iterator_value<Base>
- , remove_reference<Reference>
- >
- >::type
- # else
- , typename boost::detail::ia_dflt_help<
- Value, iterator_value<Base>
- >::type
- # endif
-
- , typename boost::detail::ia_dflt_help<
- Traversal
- , iterator_traversal<Base>
- >::type
- , typename boost::detail::ia_dflt_help<
- Reference
- , mpl::eval_if<
- is_same<Value,use_default>
- , iterator_reference<Base>
- , add_reference<Value>
- >
- >::type
- , typename boost::detail::ia_dflt_help<
- Difference, iterator_difference<Base>
- >::type
- >
- type;
- };
-
-
- template <class Tr1, class Tr2>
- inline void iterator_adaptor_assert_traversal ()
- {
- BOOST_STATIC_ASSERT((is_convertible<Tr1, Tr2>::value));
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template <
- class Derived
- , class Base
- , class Value = use_default
- , class Traversal = use_default
- , class Reference = use_default
- , class Difference = use_default
- >
- class iterator_adaptor
- : public boost::detail::iterator_adaptor_base<
- Derived, Base, Value, Traversal, Reference, Difference
- >::type
- {
- friend class iterator_core_access;
- protected:
- typedef typename boost::detail::iterator_adaptor_base<
- Derived, Base, Value, Traversal, Reference, Difference
- >::type super_t;
- public:
- iterator_adaptor() {}
- explicit iterator_adaptor(Base const &iter)
- : m_iterator(iter)
- {
- }
- typedef Base base_type;
- Base const& base() const
- { return m_iterator; }
- protected:
-
- typedef iterator_adaptor<Derived,Base,Value,Traversal,Reference,Difference> iterator_adaptor_;
-
-
-
-
- Base const& base_reference() const
- { return m_iterator; }
- Base& base_reference()
- { return m_iterator; }
- private:
-
-
-
-
-
-
- typename super_t::reference dereference() const
- { return *m_iterator; }
- template <
- class OtherDerived, class OtherIterator, class V, class C, class R, class D
- >
- bool equal(iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& x) const
- {
-
-
-
-
- return m_iterator == x.base();
- }
- typedef typename iterator_category_to_traversal<
- typename super_t::iterator_category
- >::type my_traversal;
- # define BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(cat) \
- boost::detail::iterator_adaptor_assert_traversal<my_traversal, cat>();
- void advance(typename super_t::difference_type n)
- {
- BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(random_access_traversal_tag)
- m_iterator += n;
- }
-
- void increment() { ++m_iterator; }
- void decrement()
- {
- BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(bidirectional_traversal_tag)
- --m_iterator;
- }
- template <
- class OtherDerived, class OtherIterator, class V, class C, class R, class D
- >
- typename super_t::difference_type distance_to(
- iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& y) const
- {
- BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(random_access_traversal_tag)
-
-
-
-
- return y.base() - m_iterator;
- }
- # undef BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL
-
- private:
- Base m_iterator;
- };
- }
- #include <boost/iterator/detail/config_undef.hpp>
- #endif
|