3
0
mirror of https://github.com/triqs/dft_tools synced 2024-11-01 11:43:47 +01:00
dft_tools/doc/reference/arrays/containers/reg_assign.rst

45 lines
1.1 KiB
ReStructuredText
Raw Normal View History

.. highlight:: c
2013-08-22 16:55:51 +02:00
.. _arr_reg_assign:
2013-08-22 16:55:51 +02:00
Assignment
=========================
2013-08-27 19:17:17 +02:00
**Synopsis** ::
2013-08-27 19:17:17 +02:00
array & operator=(array const & X); (1)
template<ImmutableCuboidArray RHS> array & operator=(RHS const & X); (2)
2013-08-27 19:17:17 +02:00
The container have a quite general assignment operator.
We will illustrate it on the `array` class, it is the same for `matrix` and `vector`.
2013-08-27 19:17:17 +02:00
* (1) just make a copy of X.
* (2) **RHS** can be anything that models the :ref:`ImmutableCuboidArray` concept
e.g.: array, array_view, matrix, matrix_view,
2013-08-27 19:17:17 +02:00
but also formal expression (See , e.g. A+B), or any custom object of your choice.
`Effect`: all the elements viewed by the view are replaced
2013-08-27 19:17:17 +02:00
by the evaluation of RHS.
2013-08-27 19:17:17 +02:00
.. warning::
2013-08-27 19:17:17 +02:00
In both cases, if needed, the container is resized.
Hence **assignment invalidates all pointers and views to it**.
2013-08-27 19:17:17 +02:00
Move assign operator
---------------------------
2013-08-27 19:17:17 +02:00
**Synopsis** ::
2013-08-27 19:17:17 +02:00
array & operator=(array && X);
2013-08-22 16:55:51 +02:00
2013-08-27 19:17:17 +02:00
Standard move assign operator.
Move the data of X as data of `*this`.