File indexing completed on 2025-01-18 09:38:55
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_INDIRECT_ITERATOR_23022003THW_HPP
0008 #define BOOST_INDIRECT_ITERATOR_23022003THW_HPP
0009
0010 #include <boost/iterator/iterator_adaptor.hpp>
0011
0012 #include <boost/pointee.hpp>
0013 #include <boost/indirect_reference.hpp>
0014
0015 #include <boost/detail/indirect_traits.hpp>
0016
0017 #include <boost/type_traits/is_same.hpp>
0018 #include <boost/type_traits/add_reference.hpp>
0019
0020 #include <boost/mpl/bool.hpp>
0021 #include <boost/mpl/identity.hpp>
0022 #include <boost/mpl/eval_if.hpp>
0023 #include <boost/mpl/not.hpp>
0024 #include <boost/mpl/has_xxx.hpp>
0025
0026 #include <iterator>
0027
0028 #ifdef BOOST_MPL_CFG_NO_HAS_XXX
0029 # include <boost/shared_ptr.hpp>
0030 # include <boost/scoped_ptr.hpp>
0031 # include <boost/mpl/bool.hpp>
0032 # include <memory>
0033 #endif
0034
0035 #include <boost/iterator/detail/config_def.hpp> // must be last #include
0036
0037 namespace boost {
0038 namespace iterators {
0039
0040 template <class Iter, class Value, class Category, class Reference, class Difference>
0041 class indirect_iterator;
0042
0043 namespace detail
0044 {
0045 template <class Iter, class Value, class Category, class Reference, class Difference>
0046 struct indirect_base
0047 {
0048 typedef typename std::iterator_traits<Iter>::value_type dereferenceable;
0049
0050 typedef iterator_adaptor<
0051 indirect_iterator<Iter, Value, Category, Reference, Difference>
0052 , Iter
0053 , typename ia_dflt_help<
0054 Value, pointee<dereferenceable>
0055 >::type
0056 , Category
0057 , typename ia_dflt_help<
0058 Reference
0059 , mpl::eval_if<
0060 is_same<Value,use_default>
0061 , indirect_reference<dereferenceable>
0062 , add_reference<Value>
0063 >
0064 >::type
0065 , Difference
0066 > type;
0067 };
0068
0069 template <>
0070 struct indirect_base<int, int, int, int, int> {};
0071 }
0072
0073
0074 template <
0075 class Iterator
0076 , class Value = use_default
0077 , class Category = use_default
0078 , class Reference = use_default
0079 , class Difference = use_default
0080 >
0081 class indirect_iterator
0082 : public detail::indirect_base<
0083 Iterator, Value, Category, Reference, Difference
0084 >::type
0085 {
0086 typedef typename detail::indirect_base<
0087 Iterator, Value, Category, Reference, Difference
0088 >::type super_t;
0089
0090 friend class iterator_core_access;
0091
0092 public:
0093 indirect_iterator() {}
0094
0095 indirect_iterator(Iterator iter)
0096 : super_t(iter) {}
0097
0098 template <
0099 class Iterator2, class Value2, class Category2
0100 , class Reference2, class Difference2
0101 >
0102 indirect_iterator(
0103 indirect_iterator<
0104 Iterator2, Value2, Category2, Reference2, Difference2
0105 > const& y
0106 , typename enable_if_convertible<Iterator2, Iterator>::type* = 0
0107 )
0108 : super_t(y.base())
0109 {}
0110
0111 private:
0112 typename super_t::reference dereference() const
0113 {
0114 # if BOOST_WORKAROUND(BOOST_BORLANDC, < 0x5A0 )
0115 return const_cast<super_t::reference>(**this->base());
0116 # else
0117 return **this->base();
0118 # endif
0119 }
0120 };
0121
0122 template <class Iter>
0123 inline
0124 indirect_iterator<Iter> make_indirect_iterator(Iter x)
0125 {
0126 return indirect_iterator<Iter>(x);
0127 }
0128
0129 template <class Traits, class Iter>
0130 inline
0131 indirect_iterator<Iter,Traits> make_indirect_iterator(Iter x, Traits* = 0)
0132 {
0133 return indirect_iterator<Iter, Traits>(x);
0134 }
0135
0136 }
0137
0138 using iterators::indirect_iterator;
0139 using iterators::make_indirect_iterator;
0140
0141 }
0142
0143 #include <boost/iterator/detail/config_undef.hpp>
0144
0145 #endif