Skip to content

Commit

Permalink
Fix layout_stride convertibility
Browse files Browse the repository at this point in the history
  • Loading branch information
crtrott committed Oct 23, 2023
1 parent 4b94330 commit 8328f29
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion compilation_tests/ctest_layout_convertible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ MDSPAN_STATIC_TEST(
!std::is_convertible<AStridedLayout<false>::mapping<E2>, LS1>::value
);

#if !MDSPAN_HAS_CXX_14 && !MDSPAN_HAS_CXX_20
MDSPAN_STATIC_TEST(
std::is_constructible<LS2, AStridedLayout<true>::mapping<E1>>::value &&
std::is_convertible<AStridedLayout<true>::mapping<E1>, LS2>::value
!std::is_convertible<AStridedLayout<true>::mapping<E1>, LS2>::value
);
#endif

MDSPAN_STATIC_TEST(
!std::is_constructible<LS1, NotARealLayout::mapping<E2>>::value
Expand Down
8 changes: 4 additions & 4 deletions include/experimental/__p0009_bits/layout_stride.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,10 @@ struct layout_stride {
)
#endif
MDSPAN_CONDITIONAL_EXPLICIT(
(!std::is_convertible<typename StridedLayoutMapping::extents_type, extents_type>::value) &&
(detail::__is_mapping_of<layout_left, StridedLayoutMapping> ||
detail::__is_mapping_of<layout_right, StridedLayoutMapping> ||
detail::__is_mapping_of<layout_stride, StridedLayoutMapping>)
!(std::is_convertible<typename StridedLayoutMapping::extents_type, extents_type>::value &&
(detail::__is_mapping_of<layout_left, StridedLayoutMapping> ||
detail::__is_mapping_of<layout_right, StridedLayoutMapping> ||
detail::__is_mapping_of<layout_stride, StridedLayoutMapping>))
) // needs two () due to comma
MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14
mapping(StridedLayoutMapping const& other) noexcept // NOLINT(google-explicit-constructor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ constexpr bool test() {
test_layout<std::layout_right>();
test_layout<std::layout_left>();
test_layout<std::layout_stride>();
//test_layout<always_convertible_layout>(); //FIXME
test_layout<always_convertible_layout>();
return true;
}

Expand Down

0 comments on commit 8328f29

Please sign in to comment.