2013-08-22 16:55:51 +02:00
|
|
|
.. highlight:: c
|
|
|
|
|
|
|
|
.. _partial_views:
|
|
|
|
|
|
|
|
Views
|
|
|
|
==============================================================
|
|
|
|
|
|
|
|
**Synopsis**:
|
|
|
|
|
|
|
|
.. code-block:: c
|
|
|
|
|
2014-09-07 14:34:10 +02:00
|
|
|
template <typename ValueType, int Rank, typename TraversalOrder=void> class array_view;
|
|
|
|
template <typename ValueType, typename TraversalOrder=void> class matrix_view;
|
|
|
|
template <typename ValueType> class vector_view;
|
2013-08-22 16:55:51 +02:00
|
|
|
|
2014-09-07 14:34:10 +02:00
|
|
|
template <typename ValueType, int Rank, typename TraversalOrder=void> class array_const_view;
|
|
|
|
template <typename ValueType, typename TraversalOrder=void> class matrix_const_view;
|
|
|
|
template <typename ValueType> class vector_const_view;
|
2013-08-22 16:55:51 +02:00
|
|
|
|
2013-09-18 15:13:23 +02:00
|
|
|
* The view types of X (= array, matrix, vector) are called X_view, and X_const_view, with the same template parameters as the regular type.
|
2013-08-22 16:55:51 +02:00
|
|
|
|
2013-08-27 19:17:17 +02:00
|
|
|
* A `view` is give access to a restricted portion of the array, matrix or vector, i.e. a `partial view` of the data.
|
|
|
|
The view can also be `complete` (i.e. show all the container).
|
|
|
|
|
|
|
|
* The views model the :ref:`MutableCuboidArray`, :ref:`MutableMatrix`, :ref:`MutableVector`, like the corresponding regular type.
|
|
|
|
|
2014-07-08 14:39:16 +02:00
|
|
|
* The const views are similar to view, except that theirs contents cannot be modified.
|
2013-09-18 15:13:23 +02:00
|
|
|
They model the :ref:`ImmutableCuboidArray`, :ref:`ImmutableMatrix`, :ref:`ImmutableVector`, like the corresponding *const* regular type.
|
|
|
|
|
2013-08-27 19:17:17 +02:00
|
|
|
* Views have `view semantics`, i.e. their behave like a reference to the data, they are not regular type.
|
|
|
|
In particular, they never make copy of the data.
|
|
|
|
See :ref:`view_vs_regular` for a detailed discussion of the difference between a regular type and its corresponding view.
|
|
|
|
|
2014-10-17 18:15:19 +02:00
|
|
|
* Views are largely interoperable: it is easy and quick to take a matrix_view of an array, or vice versa.
|
2013-08-27 19:17:17 +02:00
|
|
|
Cf constructors belows.
|
|
|
|
|
2013-09-18 15:13:23 +02:00
|
|
|
* Const views can be constructed from a view, but the reverse is not true (Cf constructors).
|
|
|
|
|
2013-08-27 19:17:17 +02:00
|
|
|
* **Memory Management**
|
|
|
|
|
|
|
|
Views offers a strong guarantee of the existence of the data, like a std::shared_ptr.
|
|
|
|
Cf :ref:`arr_view_memory` for details.
|
|
|
|
|
2013-08-30 11:07:39 +02:00
|
|
|
.. toctree::
|
|
|
|
:hidden:
|
|
|
|
|
|
|
|
memory
|
|
|
|
|
|
|
|
|
2013-08-27 19:17:17 +02:00
|
|
|
Template parameters
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
+-----------------------------------------+-------------------------------+-------------------------------+--------------------------------------+
|
|
|
|
| Template parameter | Accepted type | Access in the class | Meaning |
|
|
|
|
+=========================================+===============================+===============================+======================================+
|
|
|
|
| ValueType | any regular type (typically a | value_type | The type of the element of the array |
|
|
|
|
| | scalar). | | |
|
|
|
|
+-----------------------------------------+-------------------------------+-------------------------------+--------------------------------------+
|
|
|
|
| Rank | int | rank | The rank of the array |
|
|
|
|
+-----------------------------------------+-------------------------------+-------------------------------+--------------------------------------+
|
|
|
|
| :ref:`TraversalOrder<arr_templ_par_to>` | ull_t | | Traversal Order for all loops |
|
|
|
|
+-----------------------------------------+-------------------------------+-------------------------------+--------------------------------------+
|
|
|
|
|
|
|
|
NB: Rank is only present for array, since matrix have rank 2 and vector rank 1.
|
|
|
|
|
|
|
|
.. toctree::
|
|
|
|
:hidden:
|
|
|
|
|
|
|
|
template_parameters
|
|
|
|
|
|
|
|
Member types
|
|
|
|
--------------------------------------
|
|
|
|
|
2013-09-18 15:13:23 +02:00
|
|
|
+-----------------+-----------------------------------+
|
|
|
|
| Member type | Definitions |
|
|
|
|
+=================+===================================+
|
|
|
|
| value_type | ValueType |
|
|
|
|
+-----------------+-----------------------------------+
|
|
|
|
| view_type | The corresponding view type |
|
|
|
|
+-----------------+-----------------------------------+
|
|
|
|
| const_view_type | The corresponding const view type |
|
|
|
|
+-----------------+-----------------------------------+
|
|
|
|
| regular_type | The corresponding regular type |
|
|
|
|
+-----------------+-----------------------------------+
|
2013-08-27 19:17:17 +02:00
|
|
|
|
|
|
|
Member constexpr
|
|
|
|
--------------------------------------
|
|
|
|
|
|
|
|
+--------+------+-------------------------------+
|
|
|
|
| Member | Type | Definitions |
|
|
|
|
+========+======+===============================+
|
|
|
|
| rank | int | Rank of the container (Rank |
|
|
|
|
| | | for array), 2 for matrix, 1 |
|
|
|
|
| | | for vector |
|
|
|
|
+--------+------+-------------------------------+
|
|
|
|
|
|
|
|
Member functions
|
2013-09-18 15:13:23 +02:00
|
|
|
------------------
|
2013-08-27 19:17:17 +02:00
|
|
|
|
|
|
|
+-------------------------------------------+------------------------------------------+
|
|
|
|
| Member function | Meaning |
|
|
|
|
+===========================================+==========================================+
|
|
|
|
| :ref:`(constructor)<arr_view_constr>` | |
|
|
|
|
+-------------------------------------------+------------------------------------------+
|
|
|
|
| (destructor) | |
|
|
|
|
+-------------------------------------------+------------------------------------------+
|
2013-09-18 15:13:23 +02:00
|
|
|
| :ref:`operator ()<arr_call>` | element of access/views/lazy expressions |
|
|
|
|
+-------------------------------------------+------------------------------------------+
|
2013-08-27 19:17:17 +02:00
|
|
|
| :ref:`operator =<arr_view_assign>` | assigns values to the container |
|
|
|
|
+-------------------------------------------+------------------------------------------+
|
|
|
|
| :ref:`operator +=,-=,*=,/=<arr_comp_ops>` | compound assignment operators |
|
|
|
|
+-------------------------------------------+------------------------------------------+
|
|
|
|
| begin/cbegin | returns iterator to the beginning |
|
|
|
|
+-------------------------------------------+------------------------------------------+
|
|
|
|
| end/cend | returns iterator to the end |
|
|
|
|
+-------------------------------------------+------------------------------------------+
|
|
|
|
| :ref:`rebind<arr_rebind>` | rebind the view |
|
|
|
|
+-------------------------------------------+------------------------------------------+
|
|
|
|
| bool is_empty() const | Is the array empty ? |
|
|
|
|
+-------------------------------------------+------------------------------------------+
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
2014-07-08 14:39:16 +02:00
|
|
|
views cannot be resized.
|
2013-08-27 19:17:17 +02:00
|
|
|
|
|
|
|
.. toctree::
|
|
|
|
:hidden:
|
|
|
|
|
|
|
|
view_constructors
|
|
|
|
view_assign
|
|
|
|
comp_ops
|
|
|
|
call
|
|
|
|
rebind
|
|
|
|
STL
|
|
|
|
|
|
|
|
Non-member functions
|
2013-08-22 16:55:51 +02:00
|
|
|
------------------------
|
|
|
|
|
2013-08-27 19:17:17 +02:00
|
|
|
+---------------------------------+-------------------------------------------+
|
|
|
|
| Member function | Meaning |
|
|
|
|
+=================================+===========================================+
|
|
|
|
| :ref:`swap<arr_swap>` | Swap of 2 containers |
|
|
|
|
+---------------------------------+-------------------------------------------+
|
|
|
|
| :ref:`deep_swap<arr_deep_swap>` | Deep swap of the data of 2 containers ??? |
|
|
|
|
+---------------------------------+-------------------------------------------+
|
|
|
|
| :ref:`operator\<\<<arr_stream>` | Writing to stream |
|
|
|
|
+---------------------------------+-------------------------------------------+
|
2013-08-22 16:55:51 +02:00
|
|
|
|
|
|
|
|
2013-08-27 19:17:17 +02:00
|
|
|
.. toctree::
|
|
|
|
:hidden:
|
2013-08-22 16:55:51 +02:00
|
|
|
|
2013-08-27 19:17:17 +02:00
|
|
|
stream
|