1 // (C) Copyright David Abrahams 2002.
\r
2 // (C) Copyright Jeremy Siek 2002.
\r
3 // (C) Copyright Thomas Witt 2002.
\r
4 // Distributed under the Boost Software License, Version 1.0. (See
\r
5 // accompanying file LICENSE_1_0.txt or copy at
\r
6 // http://www.boost.org/LICENSE_1_0.txt)
\r
7 #ifndef BOOST_INDIRECT_ITERATOR_23022003THW_HPP
\r
8 #define BOOST_INDIRECT_ITERATOR_23022003THW_HPP
\r
10 #include <boost/iterator.hpp>
\r
11 #include <boost/iterator/iterator_adaptor.hpp>
\r
13 #include <boost/pointee.hpp>
\r
14 #include <boost/indirect_reference.hpp>
\r
15 #include <boost/detail/iterator.hpp>
\r
17 #include <boost/detail/indirect_traits.hpp>
\r
19 #include <boost/type_traits/is_same.hpp>
\r
20 #include <boost/type_traits/add_reference.hpp>
\r
22 #include <boost/mpl/bool.hpp>
\r
23 #include <boost/mpl/identity.hpp>
\r
24 #include <boost/mpl/eval_if.hpp>
\r
25 #include <boost/mpl/not.hpp>
\r
26 #include <boost/mpl/has_xxx.hpp>
\r
28 #ifdef BOOST_MPL_CFG_NO_HAS_XXX
\r
29 # include <boost/shared_ptr.hpp>
\r
30 # include <boost/scoped_ptr.hpp>
\r
31 # include <boost/mpl/bool.hpp>
\r
35 #include <boost/iterator/detail/config_def.hpp> // must be last #include
\r
39 template <class Iter, class Value, class Category, class Reference, class Difference>
\r
40 class indirect_iterator;
\r
44 template <class Iter, class Value, class Category, class Reference, class Difference>
\r
45 struct indirect_base
\r
47 typedef typename iterator_traits<Iter>::value_type dereferenceable;
\r
49 typedef iterator_adaptor<
\r
50 indirect_iterator<Iter, Value, Category, Reference, Difference>
\r
52 , typename ia_dflt_help<
\r
53 Value, pointee<dereferenceable>
\r
56 , typename ia_dflt_help<
\r
59 is_same<Value,use_default>
\r
60 , indirect_reference<dereferenceable>
\r
61 , add_reference<Value>
\r
69 struct indirect_base<int, int, int, int, int> {};
\r
70 } // namespace detail
\r
75 , class Value = use_default
\r
76 , class Category = use_default
\r
77 , class Reference = use_default
\r
78 , class Difference = use_default
\r
80 class indirect_iterator
\r
81 : public detail::indirect_base<
\r
82 Iterator, Value, Category, Reference, Difference
\r
85 typedef typename detail::indirect_base<
\r
86 Iterator, Value, Category, Reference, Difference
\r
89 friend class iterator_core_access;
\r
92 indirect_iterator() {}
\r
94 indirect_iterator(Iterator iter)
\r
98 class Iterator2, class Value2, class Category2
\r
99 , class Reference2, class Difference2
\r
103 Iterator2, Value2, Category2, Reference2, Difference2
\r
105 , typename enable_if_convertible<Iterator2, Iterator>::type* = 0
\r
107 : super_t(y.base())
\r
111 typename super_t::reference dereference() const
\r
113 # if BOOST_WORKAROUND(__BORLANDC__, < 0x5A0 )
\r
114 return const_cast<super_t::reference>(**this->base());
\r
116 return **this->base();
\r
121 template <class Iter>
\r
123 indirect_iterator<Iter> make_indirect_iterator(Iter x)
\r
125 return indirect_iterator<Iter>(x);
\r
128 template <class Traits, class Iter>
\r
130 indirect_iterator<Iter,Traits> make_indirect_iterator(Iter x, Traits* = 0)
\r
132 return indirect_iterator<Iter, Traits>(x);
\r
135 } // namespace boost
\r
137 #include <boost/iterator/detail/config_undef.hpp>
\r
139 #endif // BOOST_INDIRECT_ITERATOR_23022003THW_HPP
\r