1 // Copyright 2002 The Trustees of Indiana University.
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)
7 // Boost.MultiArray Library
8 // Authors: Ronald Garcia
11 // See http://www.boost.org/libs/multi_array for documentation.
13 #ifndef BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
14 #define BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
17 // concept-checks.hpp - Checks out Const MultiArray and MultiArray
21 #include "boost/concept_check.hpp"
22 #include "boost/iterator/iterator_concepts.hpp"
25 namespace multi_array_concepts {
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>
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);
49 struct idgen_helper<0> {
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;
62 template <typename Array, std::size_t NumDims >
63 struct ConstMultiArrayConcept
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> >();
72 // RG - a( CollectionArchetype) when available...
74 // Test slicing, keeping only the first dimension, losing the rest
75 detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
77 // Test slicing, keeping all dimensions.
78 detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
81 st = a.num_dimensions();
82 st = Array::dimensionality;
83 st = a.num_elements();
86 idp = a.index_bases();
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;
112 const size_type* stp;
116 const_reverse_iterator crit;
123 template <typename Array, std::size_t NumDims >
124 struct MutableMultiArrayConcept
127 // function_requires< CopyConstructibleConcept<Array> >();
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> >();
136 // RG - a( CollectionArchetype) when available...
137 value_type vt = a[ id ];
139 // Test slicing, keeping only the first dimension, losing the rest
140 detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
142 // Test slicing, keeping all dimensions.
143 detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
146 st = a.num_dimensions();
147 st = a.num_elements();
150 idp = a.index_bases();
156 const_constraints(a);
159 void const_constraints(const Array& a) {
161 // value_type vt = a[ id ];
163 // Test slicing, keeping only the first dimension, losing the rest
164 detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
166 // Test slicing, keeping all dimensions.
167 detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
170 st = a.num_dimensions();
171 st = a.num_elements();
174 idp = a.index_bases();
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;
200 const size_type* stp;
205 reverse_iterator rit;
206 const_reverse_iterator crit;
213 } // namespace multi_array
216 namespace multi_array { // Old locations for these
217 using boost::multi_array_concepts::ConstMultiArrayConcept;
218 using boost::multi_array_concepts::MutableMultiArrayConcept;
225 #endif // BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP