]> git.lyx.org Git - lyx.git/blob - boost/boost/multi_array/concept_checks.hpp
major boost update
[lyx.git] / boost / boost / multi_array / concept_checks.hpp
1 #ifndef BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
2 #define BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
3
4 //
5 // concept-checks.hpp - Checks out Const MultiArray and MultiArray
6 // concepts
7 //
8
9 #include "boost/concept_check.hpp"
10
11 namespace boost {
12 namespace detail {
13 namespace multi_array {
14
15   //
16   // idgen_helper -
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>
25   struct idgen_helper {
26
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);
32     }
33   };
34
35   template <>
36   struct idgen_helper<0> {
37
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;
42       a[ idgen ];
43     }
44   };
45
46
47   template <typename Array, std::size_t NumDims >
48   struct ConstMultiArrayConcept
49   {
50     void constraints() {
51       //    function_requires< CopyConstructibleConcept<Array> >();
52
53       // RG - a( CollectionArchetype) when available...
54       a[ id ];
55       // Test slicing, keeping only the first dimension, losing the rest
56       idgen_helper<NumDims-1>::call(a,idgen[range],id);
57
58       // Test slicing, keeping all dimensions.
59       idgen_helper<NumDims-1>::call(a,idgen[range],range);
60
61       st = a.size();
62       st = a.num_dimensions();
63       st = a.num_elements();
64       stp = a.shape();
65       idp = a.strides();
66       idp = a.index_bases();
67       cit = a.begin();
68       cit = a.end();
69       crit = a.rbegin();
70       crit = a.rend();
71       eltp = a.origin();
72     }
73
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;
89
90     Array a;
91     size_type st;
92     const size_type* stp;
93     index id;
94     const index* idp;
95     const_iterator cit;
96     const_reverse_iterator crit;
97     const element* eltp;
98     index_gen idgen;
99     index_range range;
100   };
101
102
103   template <typename Array, std::size_t NumDims >
104   struct MutableMultiArrayConcept
105   {
106     void constraints() {
107       //    function_requires< CopyConstructibleConcept<Array> >();
108
109       // RG - a( CollectionArchetype) when available...
110       value_type vt = a[ id ];
111
112       // Test slicing, keeping only the first dimension, losing the rest
113       idgen_helper<NumDims-1>::call(a,idgen[range],id);
114
115       // Test slicing, keeping all dimensions.
116       idgen_helper<NumDims-1>::call(a,idgen[range],range);
117
118       st = a.size();
119       st = a.num_dimensions();
120       st = a.num_elements();
121       stp = a.shape();
122       idp = a.strides();
123       idp = a.index_bases();
124       it = a.begin();
125       it = a.end();
126       rit = a.rbegin();
127       rit = a.rend();
128       eltp = a.origin();
129       const_constraints(a);
130     }
131
132     void const_constraints(const Array& a) {
133
134       //      value_type vt = a[ id ];
135
136       // Test slicing, keeping only the first dimension, losing the rest
137       idgen_helper<NumDims-1>::call(a,idgen[range],id);
138
139       // Test slicing, keeping all dimensions.
140       idgen_helper<NumDims-1>::call(a,idgen[range],range);
141
142       st = a.size();
143       st = a.num_dimensions();
144       st = a.num_elements();
145       stp = a.shape();
146       idp = a.strides();
147       idp = a.index_bases();
148       cit = a.begin();
149       cit = a.end();
150       crit = a.rbegin();
151       crit = a.rend();
152       eltp = a.origin();
153     }
154
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;
170
171     Array a;
172     size_type st;
173     const size_type* stp;
174     index id;
175     const index* idp;
176     iterator it;
177     const_iterator cit;
178     reverse_iterator rit;
179     const_reverse_iterator crit;
180     const element* eltp;
181     index_gen idgen;
182     index_range range;
183   };
184
185
186 } // namespace multi_array
187 } // namespace detail
188 } // namespace boost
189
190
191 #endif // BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP