diff --git a/include/ddc/chunk_span.hpp b/include/ddc/chunk_span.hpp index aadfefd33..0b22b5c2b 100644 --- a/include/ddc/chunk_span.hpp +++ b/include/ddc/chunk_span.hpp @@ -387,6 +387,22 @@ ChunkSpan(KokkosView const& view, DiscreteDomain domain) detail::kokkos_to_mdspan_layout_t, typename KokkosView::memory_space>; +template +ChunkSpan(Chunk& other) + -> ChunkSpan< + ElementType, + SupportType, + Kokkos::layout_right, + typename Allocator::memory_space>; + +template +ChunkSpan(Chunk const& other) + -> ChunkSpan< + const ElementType, + SupportType, + Kokkos::layout_right, + typename Allocator::memory_space>; + template < class ElementType, class SupportType, diff --git a/tests/chunk_span.cpp b/tests/chunk_span.cpp index 21688be4d..a3d8246b0 100644 --- a/tests/chunk_span.cpp +++ b/tests/chunk_span.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: MIT #include +#include #include @@ -33,3 +34,29 @@ TEST(ChunkSpan1DTest, ConstructionFromChunk) EXPECT_TRUE((std::is_constructible_v, ChunkX&>)); EXPECT_TRUE((std::is_constructible_v, ChunkX const&>)); } + +TEST(ChunkSpan1DTest, CtadFromChunk) +{ + using LvalueRefChunkType = ChunkX&; + EXPECT_TRUE((std::is_same_v< + decltype(ddc::ChunkSpan(std::declval())), + ddc::ChunkSpan>)); + + using ConstLvalueRefChunkType = ChunkX const&; + EXPECT_TRUE((std::is_same_v< + decltype(ddc::ChunkSpan(std::declval())), + ddc::ChunkSpan>)); +} + +TEST(ChunkSpan1DTest, CtadFromKokkosView) +{ + using ViewType = Kokkos::View; + EXPECT_TRUE((std::is_same_v< + decltype(ddc::ChunkSpan(std::declval(), std::declval())), + ddc::ChunkSpan>)); + + using ConstViewType = Kokkos::View; + EXPECT_TRUE((std::is_same_v< + decltype(ddc::ChunkSpan(std::declval(), std::declval())), + ddc::ChunkSpan>)); +}