-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #477 from dalg24/swap
Document `Kokkos::kokkos_swap` and associated new public header
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
``Kokkos::kokkos_swap`` | ||
======================= | ||
|
||
.. role:: cppkokkos(code) | ||
:language: cppkokkos | ||
|
||
Defined in header ``<Kokkos_Swap.hpp>``:sup:`(since 4.3)` which is included from ``<Kokkos_Core.hpp>`` | ||
|
||
.. code-block:: cpp | ||
template <class T> | ||
KOKKOS_FUNCTION constexpr void | ||
kokkos_swap(T& a, T& b) noexcept(std::is_nothrow_move_constructible_v<T> && | ||
std::is_nothrow_move_assignable_v<T>); // (1) (since 4.3) | ||
template <class T2, std::size_t N> | ||
KOKKOS_FUNCTION constexpr void | ||
kokkos_swap(T2 (&a)[N], T2 (&b)[N]) noexcept(noexcept(*a, *b)); // (2) (since 4.3) | ||
1) Swaps the values ``a`` and ``b``. This overload does not participate in overload | ||
resolution unless ``std::is_move_constructible_v<T> && std::is_move_assignable_v<T>`` | ||
is ``true``. | ||
|
||
2) Swaps the arrays ``a`` and ``b``. This overload does not participate in | ||
overload resolution unless ``T2`` is swappable. | ||
|
||
Notes | ||
----- | ||
.. _std_swap: https://en.cppreference.com/w/cpp/algorithm/swap | ||
|
||
.. |std_swap| replace:: ``std::swap`` | ||
|
||
``kokkos_swap`` provides the same functionality as |std_swap|_. It just | ||
cannot be called ``swap`` or it would yield some ambiguities in overload | ||
resolution in some situations because of `ADL | ||
<https://en.cppreference.com/w/cpp/language/adl>`_. |