123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- #ifndef BOOST_TRANSFORM_ITERATOR_23022003THW_HPP
- #define BOOST_TRANSFORM_ITERATOR_23022003THW_HPP
- #include <boost/function.hpp>
- #include <boost/iterator.hpp>
- #include <boost/iterator/detail/enable_if.hpp>
- #include <boost/iterator/iterator_adaptor.hpp>
- #include <boost/iterator/iterator_categories.hpp>
- #include <boost/mpl/not.hpp>
- #include <boost/mpl/bool.hpp>
- #include <boost/type_traits/function_traits.hpp>
- #include <boost/type_traits/is_const.hpp>
- #include <boost/type_traits/is_class.hpp>
- #include <boost/type_traits/is_function.hpp>
- #include <boost/type_traits/is_reference.hpp>
- #include <boost/type_traits/remove_const.hpp>
- #include <boost/type_traits/remove_reference.hpp>
- #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
- # include <boost/type_traits/is_base_and_derived.hpp>
- #endif
- #include <boost/iterator/detail/config_def.hpp>
- namespace boost
- {
- template <class UnaryFunction, class Iterator, class Reference = use_default, class Value = use_default>
- class transform_iterator;
- namespace detail
- {
- template <class UnaryFunc>
- struct function_object_result
- {
- typedef typename UnaryFunc::result_type type;
- };
- #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
- template <class Return, class Argument>
- struct function_object_result<Return(*)(Argument)>
- {
- typedef Return type;
- };
- #endif
-
- template <class UnaryFunc, class Iterator, class Reference, class Value>
- struct transform_iterator_base
- {
- private:
-
-
-
-
- typedef typename ia_dflt_help<
- Reference
- , function_object_result<UnaryFunc>
- >::type reference;
-
-
-
-
-
- typedef typename ia_dflt_help<
- Value
- , remove_reference<reference>
- >::type cv_value_type;
- public:
- typedef iterator_adaptor<
- transform_iterator<UnaryFunc, Iterator, Reference, Value>
- , Iterator
- , cv_value_type
- , use_default
- , reference
- > type;
- };
- }
- template <class UnaryFunc, class Iterator, class Reference, class Value>
- class transform_iterator
- : public boost::detail::transform_iterator_base<UnaryFunc, Iterator, Reference, Value>::type
- {
- typedef typename
- boost::detail::transform_iterator_base<UnaryFunc, Iterator, Reference, Value>::type
- super_t;
- friend class iterator_core_access;
- public:
- transform_iterator() { }
- transform_iterator(Iterator const& x, UnaryFunc f)
- : super_t(x), m_f(f) { }
- explicit transform_iterator(Iterator const& x)
- : super_t(x)
- {
-
-
- #if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
-
-
- BOOST_STATIC_ASSERT(is_class<UnaryFunc>::value);
- #endif
- }
- template<
- class OtherUnaryFunction
- , class OtherIterator
- , class OtherReference
- , class OtherValue>
- transform_iterator(
- transform_iterator<OtherUnaryFunction, OtherIterator, OtherReference, OtherValue> const& t
- , typename enable_if_convertible<OtherIterator, Iterator>::type* = 0
- #if !BOOST_WORKAROUND(BOOST_MSVC, == 1310)
- , typename enable_if_convertible<OtherUnaryFunction, UnaryFunc>::type* = 0
- #endif
- )
- : super_t(t.base()), m_f(t.functor())
- {}
- UnaryFunc functor() const
- { return m_f; }
- private:
- typename super_t::reference dereference() const
- { return m_f(*this->base()); }
-
-
- UnaryFunc m_f;
- };
- template <class UnaryFunc, class Iterator>
- transform_iterator<UnaryFunc, Iterator>
- make_transform_iterator(Iterator it, UnaryFunc fun)
- {
- return transform_iterator<UnaryFunc, Iterator>(it, fun);
- }
-
-
-
-
-
-
-
- template <class UnaryFunc, class Iterator>
- #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
- typename mpl::if_<
- #else
- typename iterators::enable_if<
- #endif
- is_class<UnaryFunc>
- , transform_iterator<UnaryFunc, Iterator>
- #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
- , int[3]
- #endif
- >::type
- make_transform_iterator(Iterator it)
- {
- return transform_iterator<UnaryFunc, Iterator>(it, UnaryFunc());
- }
- #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
- template <class Return, class Argument, class Iterator>
- transform_iterator< Return (*)(Argument), Iterator, Return>
- make_transform_iterator(Iterator it, Return (*fun)(Argument))
- {
- return transform_iterator<Return (*)(Argument), Iterator, Return>(it, fun);
- }
- #endif
- }
- #include <boost/iterator/detail/config_undef.hpp>
- #endif
|