mirror of
https://github.com/triqs/dft_tools
synced 2024-12-27 06:43:40 +01:00
edd1ff4529
A first general restructuration of the doc according to the pattern [tour|tutorial|reference]. In the reference part, objects are documented per topic. In each topic, [definition|c++|python|hdf5] (not yet implemented)
41 lines
977 B
ReStructuredText
41 lines
977 B
ReStructuredText
|
|
swap & deep_swap
|
|
==================================
|
|
|
|
There are two possible interpretation of "swapping two arrays":
|
|
either use 3 moves like std::swap, i.e. swapping the pointer to the data in memory,
|
|
or making a deep swap, i.e. really swapping all the elements in memeory.
|
|
|
|
.. _arr_swap:
|
|
|
|
swap
|
|
--------
|
|
|
|
* swap just exchange the (shared) pointer to the data in memory,
|
|
it does not affect the data them self.
|
|
This distinction of importance for views in particular.
|
|
|
|
* For the regular type, std::swap and swap are equivalent.
|
|
For the views, std::swap is explicitely deleted, since it is incorrect
|
|
due to the lack of move constructor for a view.
|
|
Use `swap` instead.
|
|
|
|
* **Example** :
|
|
|
|
.. triqs_example:: ./swap_0.cpp
|
|
.. _arr_deep_swap:
|
|
|
|
deep_swap
|
|
--------------
|
|
|
|
.. warning::
|
|
|
|
Currently implemented only for triqs::vector and triqs::vector_view.
|
|
|
|
|
|
* deep_swap swaps the data in memory.
|
|
|
|
* **Example** (compare with swap) :
|
|
|
|
.. triqs_example:: ./swap_1.cpp
|