1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/multi_array/concept_checks.hpp Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,214 @@
1.4 +// Copyright 2002 The Trustees of Indiana University.
1.5 +
1.6 +// Use, modification and distribution is subject to the Boost Software
1.7 +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
1.8 +// http://www.boost.org/LICENSE_1_0.txt)
1.9 +
1.10 +// Boost.MultiArray Library
1.11 +// Authors: Ronald Garcia
1.12 +// Jeremy Siek
1.13 +// Andrew Lumsdaine
1.14 +// See http://www.boost.org/libs/multi_array for documentation.
1.15 +
1.16 +#ifndef BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
1.17 +#define BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
1.18 +
1.19 +//
1.20 +// concept-checks.hpp - Checks out Const MultiArray and MultiArray
1.21 +// concepts
1.22 +//
1.23 +
1.24 +#include "boost/concept_check.hpp"
1.25 +#include "boost/iterator/iterator_concepts.hpp"
1.26 +
1.27 +namespace boost {
1.28 +namespace detail {
1.29 +namespace multi_array {
1.30 +
1.31 + //
1.32 + // idgen_helper -
1.33 + // This is a helper for generating index_gen instantiations with
1.34 + // the right type in order to test the call to
1.35 + // operator[](index_gen). Since one would normally write:
1.36 + // A[ indices[range1][range2] ]; // or
1.37 + // B[ indices[index1][index2][range1] ];
1.38 + // idgen helper allows us to generate the "indices" type by
1.39 + // creating it through recursive calls.
1.40 + template <std::size_t N>
1.41 + struct idgen_helper {
1.42 +
1.43 + template <typename Array, typename IdxGen, typename Call_Type>
1.44 + static void call(Array& a, const IdxGen& idgen, Call_Type c) {
1.45 + typedef typename Array::index_range index_range;
1.46 + typedef typename Array::index index;
1.47 + idgen_helper<N-1>::call(a,idgen[c],c);
1.48 + }
1.49 + };
1.50 +
1.51 + template <>
1.52 + struct idgen_helper<0> {
1.53 +
1.54 + template <typename Array, typename IdxGen, typename Call_Type>
1.55 + static void call(Array& a, const IdxGen& idgen, Call_Type) {
1.56 + typedef typename Array::index_range index_range;
1.57 + typedef typename Array::index index;
1.58 + a[ idgen ];
1.59 + }
1.60 + };
1.61 +
1.62 +
1.63 + template <typename Array, std::size_t NumDims >
1.64 + struct ConstMultiArrayConcept
1.65 + {
1.66 + void constraints() {
1.67 + // function_requires< CopyConstructibleConcept<Array> >();
1.68 + function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
1.69 + function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
1.70 + function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
1.71 + function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
1.72 +
1.73 + // RG - a( CollectionArchetype) when available...
1.74 + a[ id ];
1.75 + // Test slicing, keeping only the first dimension, losing the rest
1.76 + idgen_helper<NumDims-1>::call(a,idgen[range],id);
1.77 +
1.78 + // Test slicing, keeping all dimensions.
1.79 + idgen_helper<NumDims-1>::call(a,idgen[range],range);
1.80 +
1.81 + st = a.size();
1.82 + st = a.num_dimensions();
1.83 + st = a.num_elements();
1.84 + stp = a.shape();
1.85 + idp = a.strides();
1.86 + idp = a.index_bases();
1.87 + cit = a.begin();
1.88 + cit = a.end();
1.89 + crit = a.rbegin();
1.90 + crit = a.rend();
1.91 + eltp = a.origin();
1.92 + }
1.93 +
1.94 + typedef typename Array::value_type value_type;
1.95 + typedef typename Array::reference reference;
1.96 + typedef typename Array::const_reference const_reference;
1.97 + typedef typename Array::size_type size_type;
1.98 + typedef typename Array::difference_type difference_type;
1.99 + typedef typename Array::iterator iterator;
1.100 + typedef typename Array::const_iterator const_iterator;
1.101 + typedef typename Array::reverse_iterator reverse_iterator;
1.102 + typedef typename Array::const_reverse_iterator const_reverse_iterator;
1.103 + typedef typename Array::element element;
1.104 + typedef typename Array::index index;
1.105 + typedef typename Array::index_gen index_gen;
1.106 + typedef typename Array::index_range index_range;
1.107 + typedef typename Array::extent_gen extent_gen;
1.108 + typedef typename Array::extent_range extent_range;
1.109 +
1.110 + Array a;
1.111 + size_type st;
1.112 + const size_type* stp;
1.113 + index id;
1.114 + const index* idp;
1.115 + const_iterator cit;
1.116 + const_reverse_iterator crit;
1.117 + const element* eltp;
1.118 + index_gen idgen;
1.119 + index_range range;
1.120 + };
1.121 +
1.122 +
1.123 + template <typename Array, std::size_t NumDims >
1.124 + struct MutableMultiArrayConcept
1.125 + {
1.126 + void constraints() {
1.127 + // function_requires< CopyConstructibleConcept<Array> >();
1.128 +
1.129 + function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
1.130 + function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
1.131 + function_requires< boost_concepts::WritableIteratorConcept<iterator> >();
1.132 + function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
1.133 + function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
1.134 +
1.135 + // RG - a( CollectionArchetype) when available...
1.136 + value_type vt = a[ id ];
1.137 +
1.138 + // Test slicing, keeping only the first dimension, losing the rest
1.139 + idgen_helper<NumDims-1>::call(a,idgen[range],id);
1.140 +
1.141 + // Test slicing, keeping all dimensions.
1.142 + idgen_helper<NumDims-1>::call(a,idgen[range],range);
1.143 +
1.144 + st = a.size();
1.145 + st = a.num_dimensions();
1.146 + st = a.num_elements();
1.147 + stp = a.shape();
1.148 + idp = a.strides();
1.149 + idp = a.index_bases();
1.150 + it = a.begin();
1.151 + it = a.end();
1.152 + rit = a.rbegin();
1.153 + rit = a.rend();
1.154 + eltp = a.origin();
1.155 + const_constraints(a);
1.156 + }
1.157 +
1.158 + void const_constraints(const Array& a) {
1.159 +
1.160 + // value_type vt = a[ id ];
1.161 +
1.162 + // Test slicing, keeping only the first dimension, losing the rest
1.163 + idgen_helper<NumDims-1>::call(a,idgen[range],id);
1.164 +
1.165 + // Test slicing, keeping all dimensions.
1.166 + idgen_helper<NumDims-1>::call(a,idgen[range],range);
1.167 +
1.168 + st = a.size();
1.169 + st = a.num_dimensions();
1.170 + st = a.num_elements();
1.171 + stp = a.shape();
1.172 + idp = a.strides();
1.173 + idp = a.index_bases();
1.174 + cit = a.begin();
1.175 + cit = a.end();
1.176 + crit = a.rbegin();
1.177 + crit = a.rend();
1.178 + eltp = a.origin();
1.179 + }
1.180 +
1.181 + typedef typename Array::value_type value_type;
1.182 + typedef typename Array::reference reference;
1.183 + typedef typename Array::const_reference const_reference;
1.184 + typedef typename Array::size_type size_type;
1.185 + typedef typename Array::difference_type difference_type;
1.186 + typedef typename Array::iterator iterator;
1.187 + typedef typename Array::const_iterator const_iterator;
1.188 + typedef typename Array::reverse_iterator reverse_iterator;
1.189 + typedef typename Array::const_reverse_iterator const_reverse_iterator;
1.190 + typedef typename Array::element element;
1.191 + typedef typename Array::index index;
1.192 + typedef typename Array::index_gen index_gen;
1.193 + typedef typename Array::index_range index_range;
1.194 + typedef typename Array::extent_gen extent_gen;
1.195 + typedef typename Array::extent_range extent_range;
1.196 +
1.197 + Array a;
1.198 + size_type st;
1.199 + const size_type* stp;
1.200 + index id;
1.201 + const index* idp;
1.202 + iterator it;
1.203 + const_iterator cit;
1.204 + reverse_iterator rit;
1.205 + const_reverse_iterator crit;
1.206 + const element* eltp;
1.207 + index_gen idgen;
1.208 + index_range range;
1.209 + };
1.210 +
1.211 +
1.212 +} // namespace multi_array
1.213 +} // namespace detail
1.214 +} // namespace boost
1.215 +
1.216 +
1.217 +#endif // BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP