Skip to content

Commit

Permalink
Fix support for Kokkos::Array of const-qualified element type
Browse files Browse the repository at this point in the history
  • Loading branch information
dalg24 committed Apr 24, 2024
1 parent cf59f31 commit fafe861
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/Kokkos_Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ struct Array {
}

private:
template <class U = T>
friend KOKKOS_INLINE_FUNCTION constexpr std::enable_if_t<
Impl::is_swappable<T>::value>
Impl::is_swappable<U>::value>
kokkos_swap(Array<T, N>& a,
Array<T, N>& b) noexcept(Impl::is_nothrow_swappable_v<T>) {
for (std::size_t i = 0; i < N; ++i) {
Expand Down
7 changes: 7 additions & 0 deletions core/unit_test/TestArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ static_assert(test_array_aggregate_initialization());
}
}

constexpr bool test_array_const_qualified_element_type() {
Kokkos::Array<int const, 1> a{255};
return a[0] == 255;
}

static_assert(test_array_const_qualified_element_type());

// User-defined type providing a sepcialization of kokkos_swap
struct MyInt {
int i;
Expand Down

0 comments on commit fafe861

Please sign in to comment.