comparison DEPENDENCIES/generic/include/boost/range/any_range.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
comparison
equal deleted inserted replaced
15:663ca0da4350 16:2665513ce2d3
1 // Copyright Neil Groves 2010. Use, modification and
2 // distribution is subject to the Boost Software License, Version
3 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 //
6 //
7 // For more information, see http://www.boost.org/libs/range/
8 //
9 #ifndef BOOST_RANGE_ANY_RANGE_HPP_INCLUDED
10 #define BOOST_RANGE_ANY_RANGE_HPP_INCLUDED
11
12 #include <boost/config.hpp>
13 #include <boost/iterator/iterator_categories.hpp>
14 #include <boost/iterator/iterator_traits.hpp>
15 #include <boost/iterator/iterator_facade.hpp>
16 #include <boost/iterator/iterator_adaptor.hpp>
17 #include <boost/range/detail/any_iterator.hpp>
18 #include <boost/range/concepts.hpp>
19 #include <boost/range/reference.hpp>
20 #include <boost/range/value_type.hpp>
21 #include <boost/range/iterator_range_core.hpp>
22 #include <boost/cast.hpp>
23
24 namespace boost
25 {
26 namespace range_detail
27 {
28 // If T is use_default, return the result of Default, otherwise
29 // return T.
30 //
31 // This is an implementation artifact used to pick intelligent default
32 // values when the user specified boost::use_default as a template
33 // parameter.
34 template<
35 class T,
36 class Default
37 >
38 struct any_range_default_help
39 : mpl::eval_if<
40 is_same<T, use_default>
41 , Default
42 , mpl::identity<T>
43 >
44 {
45 };
46
47 template<
48 class WrappedRange
49 , class Value
50 , class Reference
51 >
52 struct any_range_value_type
53 {
54 # ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY
55 typedef typename any_range_default_help<
56 Value
57 , mpl::eval_if<
58 is_same<Reference, use_default>
59 , range_value<
60 typename remove_const<WrappedRange>
61 ::type>
62 , remove_reference<Reference>
63 >
64 >::type type;
65 # else
66 typedef typename any_range_default_help<
67 Value
68 , range_value<
69 typename remove_const<WrappedRange>
70 ::type>
71 >::type type;
72 # endif
73 };
74
75 template<
76 class Value
77 , class Traversal
78 , class Reference
79 , class Difference
80 , class Buffer = use_default
81 >
82 class any_range
83 : public iterator_range<
84 any_iterator<
85 Value
86 , Traversal
87 , Reference
88 , Difference
89 , typename any_range_default_help<
90 Buffer
91 , mpl::identity<any_iterator_default_buffer>
92 >::type
93 >
94 >
95 {
96 typedef iterator_range<
97 any_iterator<
98 Value
99 , Traversal
100 , Reference
101 , Difference
102 , typename any_range_default_help<
103 Buffer
104 , mpl::identity<any_iterator_default_buffer>
105 >::type
106 >
107 > base_type;
108
109 struct enabler {};
110 struct disabler {};
111 public:
112 any_range()
113 {
114 }
115
116 any_range(const any_range& other)
117 : base_type(other)
118 {
119 }
120
121 template<class WrappedRange>
122 any_range(WrappedRange& wrapped_range)
123 : base_type(boost::begin(wrapped_range),
124 boost::end(wrapped_range))
125 {
126 }
127
128 template<class WrappedRange>
129 any_range(const WrappedRange& wrapped_range)
130 : base_type(boost::begin(wrapped_range),
131 boost::end(wrapped_range))
132 {
133 }
134
135 template<
136 class OtherValue
137 , class OtherTraversal
138 , class OtherReference
139 , class OtherDifference
140 >
141 any_range(const any_range<
142 OtherValue
143 , OtherTraversal
144 , OtherReference
145 , OtherDifference
146 , Buffer
147 >& other)
148 : base_type(boost::begin(other), boost::end(other))
149 {
150 }
151
152 template<class Iterator>
153 any_range(Iterator first, Iterator last)
154 : base_type(first, last)
155 {
156 }
157 };
158
159 template<
160 class WrappedRange
161 , class Value = use_default
162 , class Traversal = use_default
163 , class Reference = use_default
164 , class Difference = use_default
165 , class Buffer = use_default
166 >
167 struct any_range_type_generator
168 {
169 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<WrappedRange> ));
170 typedef any_range<
171 typename any_range_value_type<
172 WrappedRange
173 , Value
174 , typename any_range_default_help<
175 Reference
176 , range_reference<WrappedRange>
177 >::type
178 >::type
179 , typename any_range_default_help<
180 Traversal
181 , iterator_traversal<
182 typename range_iterator<WrappedRange>::type
183 >
184 >::type
185 , typename any_range_default_help<
186 Reference
187 , range_reference<WrappedRange>
188 >::type
189 , typename any_range_default_help<
190 Difference
191 , range_difference<WrappedRange>
192 >::type
193 , typename any_range_default_help<
194 Buffer
195 , mpl::identity<any_iterator_default_buffer>
196 >::type
197 > type;
198 };
199 } // namespace range_detail
200
201 using range_detail::any_range;
202 using range_detail::any_range_type_generator;
203 } // namespace boost
204
205 #endif // include guard