const_multi_array_ref.xml 6.3 KB

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