• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<sect2 id="const_multi_array_ref">
2<title><literal>const_multi_array_ref</literal></title>
3
4<para>
5<literal>const_multi_array_ref</literal> is a multi-dimensional container
6adaptor.  It provides the MultiArray interface over any contiguous
7block of elements.  <literal>const_multi_array_ref</literal> exports the
8same interface as <literal>multi_array</literal>, with the exception
9of the constructors.
10</para>
11
12
13<formalpara>
14      <title>Model Of.</title>
15<para>
16<literal>const_multi_array_ref</literal> models
17<link linkend="MultiArray">MultiArray</link>,
18<ulink url="../../../libs/utility/CopyConstructible.html">CopyConstructible</ulink>.
19and depending on the element type, it may also model
20<ulink url="https://www.boost.org/sgi/stl/EqualityComparable.html">EqualityComparable</ulink> and <ulink url="https://www.boost.org/sgi/stl/LessThanComparable.html">LessThanComparable</ulink>.
21
22Detailed descriptions are provided here only for operations that are
23not described in the <literal>multi_array</literal> reference.
24</para>
25</formalpara>
26
27<formalpara>
28<title>Synopsis</title>
29
30<programlisting>
31<![CDATA[
32namespace boost {
33
34template <typename ValueType,
35          std::size_t NumDims,
36          typename TPtr = const T*>
37class const_multi_array_ref {
38public:
39// types:
40  typedef ValueType                             element;
41  typedef *unspecified*                         value_type;
42  typedef *unspecified*                         reference;
43  typedef *unspecified*                         const_reference;
44  typedef *unspecified*                         difference_type;
45  typedef *unspecified*                         iterator;
46  typedef *unspecified*                         const_iterator;
47  typedef *unspecified*                         reverse_iterator;
48  typedef *unspecified*                         const_reverse_iterator;
49  typedef multi_array_types::size_type          size_type;
50  typedef multi_array_types::index              index;
51  typedef multi_array_types::index_gen          index_gen;
52  typedef multi_array_types::index_range        index_range;
53  typedef multi_array_types::extent_gen         extent_gen;
54  typedef multi_array_types::extent_range       extent_range;
55  typedef *unspecified*                         storage_order_type;
56
57  // template typedefs
58  template <std::size_t Dims> struct            subarray;
59  template <std::size_t Dims> struct            const_subarray;
60  template <std::size_t Dims> struct            array_view;
61  template <std::size_t Dims> struct            const_array_view;
62
63
64  // structors
65
66  template <typename ExtentList>
67  explicit const_multi_array_ref(TPtr data, const ExtentList& sizes,
68                       const storage_order_type& store = c_storage_order());
69  explicit const_multi_array_ref(TPtr data, const extents_tuple& ranges,
70                       const storage_order_type& store = c_storage_order());
71  const_multi_array_ref(const const_multi_array_ref& x);
72  ~const_multi_array_ref();
73
74
75
76  // iterators:
77  const_iterator			begin() const;
78  const_iterator			end() const;
79  const_reverse_iterator		rbegin() const;
80  const_reverse_iterator		rend() const;
81
82  // capacity:
83  size_type				size() const;
84  size_type				num_elements() const;
85  size_type				num_dimensions() const;
86
87  // element access:
88  template <typename IndexList>
89    const element&		operator()(const IndexList& indices) const;
90  const_reference		operator[](index i) const;
91  const_array_view<Dims>::type	operator[](const indices_tuple& r) const;
92
93  // queries
94  const element*		data() const;
95  const element*		origin() const;
96  const size_type*		shape() const;
97  const index*			strides() const;
98  const index*			index_bases() const;
99  const storage_order_type&     storage_order() const;
100
101  // comparators
102  bool operator==(const const_multi_array_ref& rhs);
103  bool operator!=(const const_multi_array_ref& rhs);
104  bool operator<(const const_multi_array_ref& rhs);
105  bool operator>(const const_multi_array_ref& rhs);
106  bool operator>=(const const_multi_array_ref& rhs);
107  bool operator<=(const const_multi_array_ref& rhs);
108
109  // modifiers:
110  template <typename SizeList>
111  void			reshape(const SizeList& sizes)
112  template <typename BaseList>	void reindex(const BaseList& values);
113  void				reindex(index value);
114};
115]]>
116</programlisting>
117</formalpara>
118
119<formalpara>
120<title>Constructors</title>
121
122<variablelist>
123<varlistentry>
124<term><programlisting>template &lt;typename ExtentList&gt;
125explicit const_multi_array_ref(TPtr data,
126                     const ExtentList&amp; sizes,
127                     const storage_order&amp; store = c_storage_order());
128</programlisting></term>
129<listitem>
130
131<para>
132This constructs a <literal>const_multi_array_ref</literal> using the specified
133parameters.  <literal>sizes</literal> specifies the shape of the
134constructed <literal>const_multi_array_ref</literal>.  <literal>store</literal>
135specifies the storage order or layout in memory of the array
136dimensions.
137</para>
138
139<formalpara><title><literal>ExtentList</literal> Requirements</title>
140<para>
141<literal>ExtentList</literal> must model <ulink url="../../utility/Collection.html">Collection</ulink>.
142</para>
143</formalpara>
144
145<formalpara><title>Preconditions</title>
146<para><literal>sizes.size() == NumDims;</literal></para>
147</formalpara>
148
149</listitem>
150</varlistentry>
151
152<varlistentry>
153<term>
154<programlisting><![CDATA[explicit const_multi_array_ref(TPtr data,
155                     extent_gen::gen_type<NumDims>::type ranges,
156                     const storage_order& store = c_storage_order());]]>
157</programlisting></term>
158<listitem>
159<formalpara><title>Effects</title>
160<para>
161This constructs a <literal>const_multi_array_ref</literal> using the specified
162    parameters.  <literal>ranges</literal> specifies the shape and
163index bases of the constructed const_multi_array_ref. It is the result of
164<literal>NumDims</literal> chained calls to
165    <literal>extent_gen::operator[]</literal>. <literal>store</literal>
166specifies the storage order or layout in memory of the array
167dimensions.
168</para>
169</formalpara>
170</listitem>
171</varlistentry>
172
173
174<varlistentry>
175<term><programlisting>
176<![CDATA[const_multi_array_ref(const const_multi_array_ref& x);]]>
177</programlisting></term>
178<listitem>
179<formalpara>
180<title>Effects</title>
181		  <para>This constructs a shallow copy of <literal>x</literal>.
182</para></formalpara>
183</listitem>
184</varlistentry>
185
186</variablelist>
187
188</formalpara>
189
190</sect2>
191