]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/multi_array/include/boost/multi_array/concept_checks.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / multi_array / include / boost / multi_array / concept_checks.hpp
1 // Copyright 2002 The Trustees of Indiana University.
2
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 // Boost.MultiArray Library
8 // Authors: Ronald Garcia
9 // Jeremy Siek
10 // Andrew Lumsdaine
11 // See http://www.boost.org/libs/multi_array for documentation.
12
13 #ifndef BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
14 #define BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
15
16 //
17 // concept-checks.hpp - Checks out Const MultiArray and MultiArray
18 // concepts
19 //
20
21 #include "boost/concept_check.hpp"
22 #include "boost/iterator/iterator_concepts.hpp"
23
24 namespace boost {
25 namespace multi_array_concepts {
26
27 namespace detail {
28 //
29 // idgen_helper -
30 // This is a helper for generating index_gen instantiations with
31 // the right type in order to test the call to
32 // operator[](index_gen). Since one would normally write:
33 // A[ indices[range1][range2] ]; // or
34 // B[ indices[index1][index2][range1] ];
35 // idgen helper allows us to generate the "indices" type by
36 // creating it through recursive calls.
37 template <std::size_t N>
38 struct idgen_helper {
39
40 template <typename Array, typename IdxGen, typename Call_Type>
41 static void call(Array& a, const IdxGen& idgen, Call_Type c) {
42 typedef typename Array::index_range index_range;
43 typedef typename Array::index index;
44 idgen_helper<N-1>::call(a,idgen[c],c);
45 }
46 };
47
48 template <>
49 struct idgen_helper<0> {
50
51 template <typename Array, typename IdxGen, typename Call_Type>
52 static void call(Array& a, const IdxGen& idgen, Call_Type) {
53 typedef typename Array::index_range index_range;
54 typedef typename Array::index index;
55 a[ idgen ];
56 }
57 };
58
59 } // namespace detail
60
61
62 template <typename Array, std::size_t NumDims >
63 struct ConstMultiArrayConcept
64 {
65 void constraints() {
66 // function_requires< CopyConstructibleConcept<Array> >();
67 function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
68 function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
69 function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
70 function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
71
72 // RG - a( CollectionArchetype) when available...
73 a[ id ];
74 // Test slicing, keeping only the first dimension, losing the rest
75 detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
76
77 // Test slicing, keeping all dimensions.
78 detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
79
80 st = a.size();
81 st = a.num_dimensions();
82 st = Array::dimensionality;
83 st = a.num_elements();
84 stp = a.shape();
85 idp = a.strides();
86 idp = a.index_bases();
87 cit = a.begin();
88 cit = a.end();
89 crit = a.rbegin();
90 crit = a.rend();
91 eltp = a.origin();
92 }
93
94 typedef typename Array::value_type value_type;
95 typedef typename Array::reference reference;
96 typedef typename Array::const_reference const_reference;
97 typedef typename Array::size_type size_type;
98 typedef typename Array::difference_type difference_type;
99 typedef typename Array::iterator iterator;
100 typedef typename Array::const_iterator const_iterator;
101 typedef typename Array::reverse_iterator reverse_iterator;
102 typedef typename Array::const_reverse_iterator const_reverse_iterator;
103 typedef typename Array::element element;
104 typedef typename Array::index index;
105 typedef typename Array::index_gen index_gen;
106 typedef typename Array::index_range index_range;
107 typedef typename Array::extent_gen extent_gen;
108 typedef typename Array::extent_range extent_range;
109
110 Array a;
111 size_type st;
112 const size_type* stp;
113 index id;
114 const index* idp;
115 const_iterator cit;
116 const_reverse_iterator crit;
117 const element* eltp;
118 index_gen idgen;
119 index_range range;
120 };
121
122
123 template <typename Array, std::size_t NumDims >
124 struct MutableMultiArrayConcept
125 {
126 void constraints() {
127 // function_requires< CopyConstructibleConcept<Array> >();
128
129 function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
130 function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
131 function_requires< boost_concepts::WritableIteratorConcept<iterator> >();
132 function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
133 function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
134 function_requires< boost::OutputIterator<iterator,value_type> >();
135
136 // RG - a( CollectionArchetype) when available...
137 value_type vt = a[ id ];
138
139 // Test slicing, keeping only the first dimension, losing the rest
140 detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
141
142 // Test slicing, keeping all dimensions.
143 detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
144
145 st = a.size();
146 st = a.num_dimensions();
147 st = a.num_elements();
148 stp = a.shape();
149 idp = a.strides();
150 idp = a.index_bases();
151 it = a.begin();
152 it = a.end();
153 rit = a.rbegin();
154 rit = a.rend();
155 eltp = a.origin();
156 const_constraints(a);
157 }
158
159 void const_constraints(const Array& a) {
160
161 // value_type vt = a[ id ];
162
163 // Test slicing, keeping only the first dimension, losing the rest
164 detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
165
166 // Test slicing, keeping all dimensions.
167 detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
168
169 st = a.size();
170 st = a.num_dimensions();
171 st = a.num_elements();
172 stp = a.shape();
173 idp = a.strides();
174 idp = a.index_bases();
175 cit = a.begin();
176 cit = a.end();
177 crit = a.rbegin();
178 crit = a.rend();
179 eltp = a.origin();
180 }
181
182 typedef typename Array::value_type value_type;
183 typedef typename Array::reference reference;
184 typedef typename Array::const_reference const_reference;
185 typedef typename Array::size_type size_type;
186 typedef typename Array::difference_type difference_type;
187 typedef typename Array::iterator iterator;
188 typedef typename Array::const_iterator const_iterator;
189 typedef typename Array::reverse_iterator reverse_iterator;
190 typedef typename Array::const_reverse_iterator const_reverse_iterator;
191 typedef typename Array::element element;
192 typedef typename Array::index index;
193 typedef typename Array::index_gen index_gen;
194 typedef typename Array::index_range index_range;
195 typedef typename Array::extent_gen extent_gen;
196 typedef typename Array::extent_range extent_range;
197
198 Array a;
199 size_type st;
200 const size_type* stp;
201 index id;
202 const index* idp;
203 iterator it;
204 const_iterator cit;
205 reverse_iterator rit;
206 const_reverse_iterator crit;
207 const element* eltp;
208 index_gen idgen;
209 index_range range;
210 };
211
212
213 } // namespace multi_array
214
215 namespace detail {
216 namespace multi_array { // Old locations for these
217 using boost::multi_array_concepts::ConstMultiArrayConcept;
218 using boost::multi_array_concepts::MutableMultiArrayConcept;
219 }
220 }
221
222 } // namespace boost
223
224
225 #endif // BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP