Skip to content

Commit 8b4eea2

Browse files
authored
Fix layout stride converting explicit clause (#445)
* add compile test for constructibility, implicit convertability, and assignability for strided layouts * add padded layouts to explicit clause in strided layout converting constructor * don't check padded layout to strided layout conversion in < C++17 * address review
1 parent 5d4eb20 commit 8b4eea2

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

compilation_tests/ctest_layout_convertible.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,24 @@ MDSPAN_STATIC_TEST(
9191
!std::is_constructible<LS1, NotARealLayout::mapping<E2>>::value
9292
);
9393

94-
94+
MDSPAN_STATIC_TEST(std::is_constructible<LS1, Kokkos::layout_left::mapping<E1>>::value);
95+
MDSPAN_STATIC_TEST(std::is_convertible<Kokkos::layout_left::mapping<E1>, LS1>::value);
96+
MDSPAN_STATIC_TEST(std::is_assignable<LS1, Kokkos::layout_left::mapping<E1>>::value);
97+
98+
MDSPAN_STATIC_TEST(std::is_constructible<LS1, Kokkos::layout_right::mapping<E1>>::value);
99+
MDSPAN_STATIC_TEST(std::is_convertible<Kokkos::layout_right::mapping<E1>, LS1>::value);
100+
MDSPAN_STATIC_TEST(std::is_assignable<LS1, Kokkos::layout_right::mapping<E1>>::value);
101+
102+
MDSPAN_STATIC_TEST(std::is_constructible<LS1, Kokkos::layout_stride::mapping<E1>>::value);
103+
MDSPAN_STATIC_TEST(std::is_convertible<Kokkos::layout_stride::mapping<E1>, LS1>::value);
104+
MDSPAN_STATIC_TEST(std::is_assignable<LS1, Kokkos::layout_stride::mapping<E1>>::value);
105+
106+
#if MDSPAN_HAS_CXX_17
107+
MDSPAN_STATIC_TEST(std::is_constructible<LS1, Kokkos::Experimental::layout_left_padded<14>::mapping<E1>>::value);
108+
MDSPAN_STATIC_TEST(std::is_convertible<Kokkos::Experimental::layout_left_padded<14>::mapping<E1>, LS1>::value);
109+
MDSPAN_STATIC_TEST(std::is_assignable<LS1, Kokkos::Experimental::layout_left_padded<14>::mapping<E1>>::value);
110+
111+
MDSPAN_STATIC_TEST(std::is_constructible<LS1, Kokkos::Experimental::layout_right_padded<14>::mapping<E1>>::value);
112+
MDSPAN_STATIC_TEST(std::is_convertible<Kokkos::Experimental::layout_right_padded<14>::mapping<E1>, LS1>::value);
113+
MDSPAN_STATIC_TEST(std::is_assignable<LS1, Kokkos::Experimental::layout_right_padded<14>::mapping<E1>>::value);
114+
#endif

include/experimental/__p0009_bits/layout_stride.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
#include "compressed_pair.hpp"
2222
#include "utility.hpp"
2323

24+
#if MDSPAN_HAS_CXX_17
25+
#include "../__p2642_bits/layout_padded_fwd.hpp"
26+
#endif
27+
2428
#if !defined(MDSPAN_IMPL_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS)
2529
# include "no_unique_address.hpp"
2630
#endif
@@ -441,6 +445,8 @@ struct layout_stride {
441445
!(std::is_convertible<typename StridedLayoutMapping::extents_type, extents_type>::value &&
442446
(detail::is_mapping_of<layout_left, StridedLayoutMapping> ||
443447
detail::is_mapping_of<layout_right, StridedLayoutMapping> ||
448+
MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::is_layout_left_padded_mapping<StridedLayoutMapping>::value || // Don't need to guard for C++14 as this isn't compiled in < C++20
449+
MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::is_layout_right_padded_mapping<StridedLayoutMapping>::value ||
444450
detail::is_mapping_of<layout_stride, StridedLayoutMapping>))
445451
) // needs two () due to comma
446452
MDSPAN_INLINE_FUNCTION MDSPAN_IMPL_CONSTEXPR_14

0 commit comments

Comments
 (0)