]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/iterator/indirect_iterator.hpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
64dde30b5f76c1a3263b4116f2cac536f3cd5c48
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / iterator / indirect_iterator.hpp
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
9 \r
10 #include <boost/iterator.hpp>\r
11 #include <boost/iterator/iterator_adaptor.hpp>\r
12 \r
13 #include <boost/pointee.hpp>\r
14 #include <boost/indirect_reference.hpp>\r
15 #include <boost/detail/iterator.hpp>\r
16 \r
17 #include <boost/detail/indirect_traits.hpp>\r
18 \r
19 #include <boost/type_traits/is_same.hpp>\r
20 #include <boost/type_traits/add_reference.hpp>\r
21 \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
27 \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
32 # include <memory>\r
33 #endif \r
34 \r
35 #include <boost/iterator/detail/config_def.hpp> // must be last #include\r
36 \r
37 namespace boost\r
38 {\r
39   template <class Iter, class Value, class Category, class Reference, class Difference>\r
40   class indirect_iterator;\r
41 \r
42   namespace detail\r
43   {\r
44     template <class Iter, class Value, class Category, class Reference, class Difference>\r
45     struct indirect_base\r
46     {\r
47         typedef typename iterator_traits<Iter>::value_type dereferenceable;\r
48         \r
49         typedef iterator_adaptor<\r
50             indirect_iterator<Iter, Value, Category, Reference, Difference>\r
51           , Iter\r
52           , typename ia_dflt_help<\r
53                 Value, pointee<dereferenceable>\r
54             >::type\r
55           , Category\r
56           , typename ia_dflt_help<\r
57                 Reference\r
58               , mpl::eval_if<\r
59                     is_same<Value,use_default>\r
60                   , indirect_reference<dereferenceable>\r
61                   , add_reference<Value>\r
62                 >\r
63             >::type\r
64           , Difference\r
65         > type;\r
66     };\r
67 \r
68     template <>\r
69     struct indirect_base<int, int, int, int, int> {};\r
70   } // namespace detail\r
71 \r
72     \r
73   template <\r
74       class Iterator\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
79   >\r
80   class indirect_iterator\r
81     : public detail::indirect_base<\r
82         Iterator, Value, Category, Reference, Difference\r
83       >::type\r
84   {\r
85       typedef typename detail::indirect_base<\r
86           Iterator, Value, Category, Reference, Difference\r
87       >::type super_t;\r
88 \r
89       friend class iterator_core_access;\r
90 \r
91    public:\r
92       indirect_iterator() {}\r
93 \r
94       indirect_iterator(Iterator iter)\r
95         : super_t(iter) {}\r
96 \r
97       template <\r
98           class Iterator2, class Value2, class Category2\r
99         , class Reference2, class Difference2\r
100       >\r
101       indirect_iterator(\r
102           indirect_iterator<\r
103                Iterator2, Value2, Category2, Reference2, Difference2\r
104           > const& y\r
105         , typename enable_if_convertible<Iterator2, Iterator>::type* = 0\r
106       )\r
107         : super_t(y.base())\r
108       {}\r
109 \r
110   private:    \r
111       typename super_t::reference dereference() const\r
112       {\r
113 # if BOOST_WORKAROUND(__BORLANDC__, < 0x5A0 )\r
114           return const_cast<super_t::reference>(**this->base());\r
115 # else\r
116           return **this->base();\r
117 # endif \r
118       }\r
119   };\r
120 \r
121   template <class Iter>\r
122   inline\r
123   indirect_iterator<Iter> make_indirect_iterator(Iter x)\r
124   {\r
125     return indirect_iterator<Iter>(x);\r
126   }\r
127 \r
128   template <class Traits, class Iter>\r
129   inline\r
130   indirect_iterator<Iter,Traits> make_indirect_iterator(Iter x, Traits* = 0)\r
131   {\r
132     return indirect_iterator<Iter, Traits>(x);\r
133   }\r
134 \r
135 } // namespace boost\r
136 \r
137 #include <boost/iterator/detail/config_undef.hpp>\r
138 \r
139 #endif // BOOST_INDIRECT_ITERATOR_23022003THW_HPP\r