17 #ifndef KOKKOS_SWAP_HPP
18 #define KOKKOS_SWAP_HPP
20 #include <Kokkos_Macros.hpp>
23 #include <type_traits>
29 KOKKOS_FUNCTION constexpr std::enable_if_t<std::is_move_constructible_v<T> &&
30 std::is_move_assignable_v<T>>
31 kokkos_swap(T& a, T& b) noexcept(std::is_nothrow_move_constructible_v<T>&&
32 std::is_nothrow_move_assignable_v<T>) {
43 static decltype(kokkos_swap(std::declval<T&>(), std::declval<T&>()))
47 static Nope test_swap(
long);
48 static constexpr
bool value =
49 !std::is_same_v<decltype(test_swap<T>(0)), Nope>;
53 inline constexpr
bool is_nothrow_swappable_v =
54 noexcept(kokkos_swap(std::declval<T&>(), std::declval<T&>()));
58 template <class T, std::
size_t N>
59 KOKKOS_FUNCTION constexpr std::enable_if_t<Impl::is_swappable<T>::value>
60 kokkos_swap(T (&a)[N], T (&b)[N]) noexcept(Impl::is_nothrow_swappable_v<T>) {
61 for (std::size_t i = 0; i < N; ++i) {
62 kokkos_swap(a[i], b[i]);