Skip to content

Commit

Permalink
Make layout_stride::stride() constraints standard compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
crtrott committed Oct 20, 2023
1 parent 9ff2207 commit 1927de0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
6 changes: 1 addition & 5 deletions include/experimental/__p0009_bits/layout_stride.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,7 @@ struct layout_stride {


MDSPAN_INLINE_FUNCTION
constexpr index_type stride(rank_type r) const noexcept
#if MDSPAN_HAS_CXX_20
requires ( Extents::rank() > 0 )
#endif
{
constexpr index_type stride(rank_type r) const noexcept {
return __strides_storage()[r];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ test_layout_mapping_stride(E ext, std::array<typename E::index_type, E::rank()>

constexpr bool test() {
constexpr size_t D = std::dynamic_extent;
//test_layout_mapping_stride(std::extents<int>(), std::array<int, 0>{}, true); //FIXME
test_layout_mapping_stride(std::extents<int>(), std::array<int, 0>{}, true);
test_layout_mapping_stride(std::extents<char, 4, 5>(), std::array<char, 2>{1, 4}, true);
test_layout_mapping_stride(std::extents<char, 4, 5>(), std::array<char, 2>{1, 5}, false);
test_layout_mapping_stride(std::extents<unsigned, D, 4>(7), std::array<unsigned, 2>{20, 2}, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void test_layout_mapping_stride() {

int main(int, char**) {
constexpr size_t D = std::dynamic_extent;
//test_layout_mapping_stride<std::extents<int>>(); //FIXME
test_layout_mapping_stride<std::extents<int>>();
test_layout_mapping_stride<std::extents<char, 4, 5>>();
test_layout_mapping_stride<std::extents<unsigned, D, 4>>();
test_layout_mapping_stride<std::extents<size_t, D, D, D, D>>();
Expand Down
3 changes: 2 additions & 1 deletion tests/test_layout_stride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ TEST(TestLayoutStrideStrideConstraint, test_layout_stride_stride_constraint) {

Kokkos::extents<int> ext0d{};
Kokkos::layout_stride::mapping m0d{ext0d, std::array<int,0>{}};
ASSERT_FALSE((is_stride_avail< decltype(m0d), int >::value));
// This is weird, but its what the standard says
ASSERT_TRUE((is_stride_avail< decltype(m0d), int >::value));
}
#endif

0 comments on commit 1927de0

Please sign in to comment.