1 #ifndef BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
2 #define BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
5 // concept-checks.hpp - Checks out Const MultiArray and MultiArray
9 #include "boost/concept_check.hpp"
13 namespace multi_array {
17 // This is a helper for generating index_gen instantiations with
18 // the right type in order to test the call to
19 // operator[](index_gen). Since one would normally write:
20 // A[ indices[range1][range2] ]; // or
21 // B[ indices[index1][index2][range1] ];
22 // idgen helper allows us to generate the "indices" type by
23 // creating it through recursive calls.
24 template <std::size_t N>
27 template <typename Array, typename IdxGen, typename Call_Type>
28 static void call(Array& a, const IdxGen& idgen, Call_Type c) {
29 typedef typename Array::index_range index_range;
30 typedef typename Array::index index;
31 idgen_helper<N-1>::call(a,idgen[c],c);
36 struct idgen_helper<0> {
38 template <typename Array, typename IdxGen, typename Call_Type>
39 static void call(Array& a, const IdxGen& idgen, Call_Type) {
40 typedef typename Array::index_range index_range;
41 typedef typename Array::index index;
47 template <typename Array, std::size_t NumDims >
48 struct ConstMultiArrayConcept
51 // function_requires< CopyConstructibleConcept<Array> >();
53 // RG - a( CollectionArchetype) when available...
55 // Test slicing, keeping only the first dimension, losing the rest
56 idgen_helper<NumDims-1>::call(a,idgen[range],id);
58 // Test slicing, keeping all dimensions.
59 idgen_helper<NumDims-1>::call(a,idgen[range],range);
62 st = a.num_dimensions();
63 st = a.num_elements();
66 idp = a.index_bases();
74 typedef typename Array::value_type value_type;
75 typedef typename Array::reference reference;
76 typedef typename Array::const_reference const_reference;
77 typedef typename Array::size_type size_type;
78 typedef typename Array::difference_type difference_type;
79 typedef typename Array::iterator iterator;
80 typedef typename Array::const_iterator const_iterator;
81 typedef typename Array::reverse_iterator reverse_iterator;
82 typedef typename Array::const_reverse_iterator const_reverse_iterator;
83 typedef typename Array::element element;
84 typedef typename Array::index index;
85 typedef typename Array::index_gen index_gen;
86 typedef typename Array::index_range index_range;
87 typedef typename Array::extent_gen extent_gen;
88 typedef typename Array::extent_range extent_range;
96 const_reverse_iterator crit;
103 template <typename Array, std::size_t NumDims >
104 struct MutableMultiArrayConcept
107 // function_requires< CopyConstructibleConcept<Array> >();
109 // RG - a( CollectionArchetype) when available...
110 value_type vt = a[ id ];
112 // Test slicing, keeping only the first dimension, losing the rest
113 idgen_helper<NumDims-1>::call(a,idgen[range],id);
115 // Test slicing, keeping all dimensions.
116 idgen_helper<NumDims-1>::call(a,idgen[range],range);
119 st = a.num_dimensions();
120 st = a.num_elements();
123 idp = a.index_bases();
129 const_constraints(a);
132 void const_constraints(const Array& a) {
134 // value_type vt = a[ id ];
136 // Test slicing, keeping only the first dimension, losing the rest
137 idgen_helper<NumDims-1>::call(a,idgen[range],id);
139 // Test slicing, keeping all dimensions.
140 idgen_helper<NumDims-1>::call(a,idgen[range],range);
143 st = a.num_dimensions();
144 st = a.num_elements();
147 idp = a.index_bases();
155 typedef typename Array::value_type value_type;
156 typedef typename Array::reference reference;
157 typedef typename Array::const_reference const_reference;
158 typedef typename Array::size_type size_type;
159 typedef typename Array::difference_type difference_type;
160 typedef typename Array::iterator iterator;
161 typedef typename Array::const_iterator const_iterator;
162 typedef typename Array::reverse_iterator reverse_iterator;
163 typedef typename Array::const_reverse_iterator const_reverse_iterator;
164 typedef typename Array::element element;
165 typedef typename Array::index index;
166 typedef typename Array::index_gen index_gen;
167 typedef typename Array::index_range index_range;
168 typedef typename Array::extent_gen extent_gen;
169 typedef typename Array::extent_range extent_range;
173 const size_type* stp;
178 reverse_iterator rit;
179 const_reverse_iterator crit;
186 } // namespace multi_array
187 } // namespace detail
191 #endif // BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP