]> git.lyx.org Git - lyx.git/blob - boost/boost/multi_array/concept_checks.hpp
complie fix
[lyx.git] / boost / boost / multi_array / concept_checks.hpp
1 // Copyright (C) 2002 Ronald Garcia
2 //
3 // Permission to copy, use, sell and distribute this software is granted
4 // provided this copyright notice appears in all copies. 
5 // Permission to modify the code and to distribute modified code is granted
6 // provided this copyright notice appears in all copies, and a notice 
7 // that the code was modified is included with the copyright notice.
8 //
9 // This software is provided "as is" without express or implied warranty, 
10 // and with no claim as to its suitability for any purpose.
11 //
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
23 namespace boost {
24 namespace detail {
25 namespace multi_array {
26
27   //
28   // idgen_helper -
29   //   This is a helper for generating index_gen instantiations with
30   //   the right type in order to test the call to
31   //   operator[](index_gen).  Since one would normally write:
32   //      A[ indices[range1][range2] ]; // or
33   //      B[ indices[index1][index2][range1] ];
34   //   idgen helper allows us to generate the "indices" type by
35   //   creating it through recursive calls.
36   template <std::size_t N>
37   struct idgen_helper {
38
39     template <typename Array, typename IdxGen, typename Call_Type>
40     static void call(Array& a, const IdxGen& idgen, Call_Type c) {
41       typedef typename Array::index_range index_range;
42       typedef typename Array::index index;
43       idgen_helper<N-1>::call(a,idgen[c],c);
44     }
45   };
46
47   template <>
48   struct idgen_helper<0> {
49
50     template <typename Array, typename IdxGen, typename Call_Type>
51     static void call(Array& a, const IdxGen& idgen, Call_Type) {
52       typedef typename Array::index_range index_range;
53       typedef typename Array::index index;
54       a[ idgen ];
55     }
56   };
57
58
59   template <typename Array, std::size_t NumDims >
60   struct ConstMultiArrayConcept
61   {
62     void constraints() {
63       //    function_requires< CopyConstructibleConcept<Array> >();
64
65       // RG - a( CollectionArchetype) when available...
66       a[ id ];
67       // Test slicing, keeping only the first dimension, losing the rest
68       idgen_helper<NumDims-1>::call(a,idgen[range],id);
69
70       // Test slicing, keeping all dimensions.
71       idgen_helper<NumDims-1>::call(a,idgen[range],range);
72
73       st = a.size();
74       st = a.num_dimensions();
75       st = a.num_elements();
76       stp = a.shape();
77       idp = a.strides();
78       idp = a.index_bases();
79       cit = a.begin();
80       cit = a.end();
81       crit = a.rbegin();
82       crit = a.rend();
83       eltp = a.origin();
84     }
85
86     typedef typename Array::value_type value_type;
87     typedef typename Array::reference reference;
88     typedef typename Array::const_reference const_reference;
89     typedef typename Array::size_type size_type;
90     typedef typename Array::difference_type difference_type;
91     typedef typename Array::iterator iterator;
92     typedef typename Array::const_iterator const_iterator;
93     typedef typename Array::reverse_iterator reverse_iterator;
94     typedef typename Array::const_reverse_iterator const_reverse_iterator;
95     typedef typename Array::element element;
96     typedef typename Array::index index;
97     typedef typename Array::index_gen index_gen;
98     typedef typename Array::index_range index_range;
99     typedef typename Array::extent_gen extent_gen;
100     typedef typename Array::extent_range extent_range;
101
102     Array a;
103     size_type st;
104     const size_type* stp;
105     index id;
106     const index* idp;
107     const_iterator cit;
108     const_reverse_iterator crit;
109     const element* eltp;
110     index_gen idgen;
111     index_range range;
112   };
113
114
115   template <typename Array, std::size_t NumDims >
116   struct MutableMultiArrayConcept
117   {
118     void constraints() {
119       //    function_requires< CopyConstructibleConcept<Array> >();
120
121       // RG - a( CollectionArchetype) when available...
122       value_type vt = a[ id ];
123
124       // Test slicing, keeping only the first dimension, losing the rest
125       idgen_helper<NumDims-1>::call(a,idgen[range],id);
126
127       // Test slicing, keeping all dimensions.
128       idgen_helper<NumDims-1>::call(a,idgen[range],range);
129
130       st = a.size();
131       st = a.num_dimensions();
132       st = a.num_elements();
133       stp = a.shape();
134       idp = a.strides();
135       idp = a.index_bases();
136       it = a.begin();
137       it = a.end();
138       rit = a.rbegin();
139       rit = a.rend();
140       eltp = a.origin();
141       const_constraints(a);
142     }
143
144     void const_constraints(const Array& a) {
145
146       //      value_type vt = a[ id ];
147
148       // Test slicing, keeping only the first dimension, losing the rest
149       idgen_helper<NumDims-1>::call(a,idgen[range],id);
150
151       // Test slicing, keeping all dimensions.
152       idgen_helper<NumDims-1>::call(a,idgen[range],range);
153
154       st = a.size();
155       st = a.num_dimensions();
156       st = a.num_elements();
157       stp = a.shape();
158       idp = a.strides();
159       idp = a.index_bases();
160       cit = a.begin();
161       cit = a.end();
162       crit = a.rbegin();
163       crit = a.rend();
164       eltp = a.origin();
165     }
166
167     typedef typename Array::value_type value_type;
168     typedef typename Array::reference reference;
169     typedef typename Array::const_reference const_reference;
170     typedef typename Array::size_type size_type;
171     typedef typename Array::difference_type difference_type;
172     typedef typename Array::iterator iterator;
173     typedef typename Array::const_iterator const_iterator;
174     typedef typename Array::reverse_iterator reverse_iterator;
175     typedef typename Array::const_reverse_iterator const_reverse_iterator;
176     typedef typename Array::element element;
177     typedef typename Array::index index;
178     typedef typename Array::index_gen index_gen;
179     typedef typename Array::index_range index_range;
180     typedef typename Array::extent_gen extent_gen;
181     typedef typename Array::extent_range extent_range;
182
183     Array a;
184     size_type st;
185     const size_type* stp;
186     index id;
187     const index* idp;
188     iterator it;
189     const_iterator cit;
190     reverse_iterator rit;
191     const_reverse_iterator crit;
192     const element* eltp;
193     index_gen idgen;
194     index_range range;
195   };
196
197
198 } // namespace multi_array
199 } // namespace detail
200 } // namespace boost
201
202
203 #endif // BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP