diff --git a/docs/source/API/core/Utilities.rst b/docs/source/API/core/Utilities.rst index 67f973bfd..025d1fd69 100644 --- a/docs/source/API/core/Utilities.rst +++ b/docs/source/API/core/Utilities.rst @@ -10,6 +10,7 @@ Utilities ./utilities/complex ./utilities/min_max_clamp ./utilities/printf + ./utilities/swap ./utilities/timer ./utilities/device_id ./utilities/num_threads diff --git a/docs/source/API/core/utilities/swap.rst b/docs/source/API/core/utilities/swap.rst new file mode 100644 index 000000000..7a84e1f61 --- /dev/null +++ b/docs/source/API/core/utilities/swap.rst @@ -0,0 +1,37 @@ +``Kokkos::kokkos_swap`` +======================= + +.. role:: cppkokkos(code) + :language: cppkokkos + +Defined in header ````:sup:`(since 4.3)` which is included from ```` + +.. code-block:: cpp + + template + KOKKOS_FUNCTION constexpr void + kokkos_swap(T& a, T& b) noexcept(std::is_nothrow_move_constructible_v && + std::is_nothrow_move_assignable_v); // (1) (since 4.3) + + template + 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 && std::is_move_assignable_v`` + 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 +`_.