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 detail {
|
---|
26 | namespace multi_array {
|
---|
27 |
|
---|
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 |
|
---|
60 | template <typename Array, std::size_t NumDims >
|
---|
61 | struct ConstMultiArrayConcept
|
---|
62 | {
|
---|
63 | void constraints() {
|
---|
64 | // function_requires< CopyConstructibleConcept<Array> >();
|
---|
65 | function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
|
---|
66 | function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
|
---|
67 | function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
|
---|
68 | function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
|
---|
69 |
|
---|
70 | // RG - a( CollectionArchetype) when available...
|
---|
71 | a[ id ];
|
---|
72 | // Test slicing, keeping only the first dimension, losing the rest
|
---|
73 | idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
---|
74 |
|
---|
75 | // Test slicing, keeping all dimensions.
|
---|
76 | idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
---|
77 |
|
---|
78 | st = a.size();
|
---|
79 | st = a.num_dimensions();
|
---|
80 | st = a.num_elements();
|
---|
81 | stp = a.shape();
|
---|
82 | idp = a.strides();
|
---|
83 | idp = a.index_bases();
|
---|
84 | cit = a.begin();
|
---|
85 | cit = a.end();
|
---|
86 | crit = a.rbegin();
|
---|
87 | crit = a.rend();
|
---|
88 | eltp = a.origin();
|
---|
89 | }
|
---|
90 |
|
---|
91 | typedef typename Array::value_type value_type;
|
---|
92 | typedef typename Array::reference reference;
|
---|
93 | typedef typename Array::const_reference const_reference;
|
---|
94 | typedef typename Array::size_type size_type;
|
---|
95 | typedef typename Array::difference_type difference_type;
|
---|
96 | typedef typename Array::iterator iterator;
|
---|
97 | typedef typename Array::const_iterator const_iterator;
|
---|
98 | typedef typename Array::reverse_iterator reverse_iterator;
|
---|
99 | typedef typename Array::const_reverse_iterator const_reverse_iterator;
|
---|
100 | typedef typename Array::element element;
|
---|
101 | typedef typename Array::index index;
|
---|
102 | typedef typename Array::index_gen index_gen;
|
---|
103 | typedef typename Array::index_range index_range;
|
---|
104 | typedef typename Array::extent_gen extent_gen;
|
---|
105 | typedef typename Array::extent_range extent_range;
|
---|
106 |
|
---|
107 | Array a;
|
---|
108 | size_type st;
|
---|
109 | const size_type* stp;
|
---|
110 | index id;
|
---|
111 | const index* idp;
|
---|
112 | const_iterator cit;
|
---|
113 | const_reverse_iterator crit;
|
---|
114 | const element* eltp;
|
---|
115 | index_gen idgen;
|
---|
116 | index_range range;
|
---|
117 | };
|
---|
118 |
|
---|
119 |
|
---|
120 | template <typename Array, std::size_t NumDims >
|
---|
121 | struct MutableMultiArrayConcept
|
---|
122 | {
|
---|
123 | void constraints() {
|
---|
124 | // function_requires< CopyConstructibleConcept<Array> >();
|
---|
125 |
|
---|
126 | function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
|
---|
127 | function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
|
---|
128 | function_requires< boost_concepts::WritableIteratorConcept<iterator> >();
|
---|
129 | function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
|
---|
130 | function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
|
---|
131 |
|
---|
132 | // RG - a( CollectionArchetype) when available...
|
---|
133 | value_type vt = a[ id ];
|
---|
134 |
|
---|
135 | // Test slicing, keeping only the first dimension, losing the rest
|
---|
136 | idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
---|
137 |
|
---|
138 | // Test slicing, keeping all dimensions.
|
---|
139 | idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
---|
140 |
|
---|
141 | st = a.size();
|
---|
142 | st = a.num_dimensions();
|
---|
143 | st = a.num_elements();
|
---|
144 | stp = a.shape();
|
---|
145 | idp = a.strides();
|
---|
146 | idp = a.index_bases();
|
---|
147 | it = a.begin();
|
---|
148 | it = a.end();
|
---|
149 | rit = a.rbegin();
|
---|
150 | rit = a.rend();
|
---|
151 | eltp = a.origin();
|
---|
152 | const_constraints(a);
|
---|
153 | }
|
---|
154 |
|
---|
155 | void const_constraints(const Array& a) {
|
---|
156 |
|
---|
157 | // value_type vt = a[ id ];
|
---|
158 |
|
---|
159 | // Test slicing, keeping only the first dimension, losing the rest
|
---|
160 | idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
---|
161 |
|
---|
162 | // Test slicing, keeping all dimensions.
|
---|
163 | idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
---|
164 |
|
---|
165 | st = a.size();
|
---|
166 | st = a.num_dimensions();
|
---|
167 | st = a.num_elements();
|
---|
168 | stp = a.shape();
|
---|
169 | idp = a.strides();
|
---|
170 | idp = a.index_bases();
|
---|
171 | cit = a.begin();
|
---|
172 | cit = a.end();
|
---|
173 | crit = a.rbegin();
|
---|
174 | crit = a.rend();
|
---|
175 | eltp = a.origin();
|
---|
176 | }
|
---|
177 |
|
---|
178 | typedef typename Array::value_type value_type;
|
---|
179 | typedef typename Array::reference reference;
|
---|
180 | typedef typename Array::const_reference const_reference;
|
---|
181 | typedef typename Array::size_type size_type;
|
---|
182 | typedef typename Array::difference_type difference_type;
|
---|
183 | typedef typename Array::iterator iterator;
|
---|
184 | typedef typename Array::const_iterator const_iterator;
|
---|
185 | typedef typename Array::reverse_iterator reverse_iterator;
|
---|
186 | typedef typename Array::const_reverse_iterator const_reverse_iterator;
|
---|
187 | typedef typename Array::element element;
|
---|
188 | typedef typename Array::index index;
|
---|
189 | typedef typename Array::index_gen index_gen;
|
---|
190 | typedef typename Array::index_range index_range;
|
---|
191 | typedef typename Array::extent_gen extent_gen;
|
---|
192 | typedef typename Array::extent_range extent_range;
|
---|
193 |
|
---|
194 | Array a;
|
---|
195 | size_type st;
|
---|
196 | const size_type* stp;
|
---|
197 | index id;
|
---|
198 | const index* idp;
|
---|
199 | iterator it;
|
---|
200 | const_iterator cit;
|
---|
201 | reverse_iterator rit;
|
---|
202 | const_reverse_iterator crit;
|
---|
203 | const element* eltp;
|
---|
204 | index_gen idgen;
|
---|
205 | index_range range;
|
---|
206 | };
|
---|
207 |
|
---|
208 |
|
---|
209 | } // namespace multi_array
|
---|
210 | } // namespace detail
|
---|
211 | } // namespace boost
|
---|
212 |
|
---|
213 |
|
---|
214 | #endif // BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
|
---|