From 46540a1248a0ec5a0f8451e598336aef6ae4c694 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 19 Jan 2026 11:49:28 -0500 Subject: [PATCH 1/4] add compile test for constructibility, implicit convertability, and assignability for strided layouts --- compilation_tests/ctest_layout_convertible.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/compilation_tests/ctest_layout_convertible.cpp b/compilation_tests/ctest_layout_convertible.cpp index 2da8b84e..fc7a0b3f 100644 --- a/compilation_tests/ctest_layout_convertible.cpp +++ b/compilation_tests/ctest_layout_convertible.cpp @@ -91,4 +91,22 @@ MDSPAN_STATIC_TEST( !std::is_constructible>::value ); +MDSPAN_STATIC_TEST(std::is_constructible, LS1>::value); +MDSPAN_STATIC_TEST(std::is_convertible, LS1>::value); +MDSPAN_STATIC_TEST(std::is_assignable>::value); +MDSPAN_STATIC_TEST(std::is_constructible, LS1>::value); +MDSPAN_STATIC_TEST(std::is_convertible, LS1>::value); +MDSPAN_STATIC_TEST(std::is_assignable>::value); + +MDSPAN_STATIC_TEST(std::is_constructible, LS1>::value); +MDSPAN_STATIC_TEST(std::is_convertible, LS1>::value); +MDSPAN_STATIC_TEST(std::is_assignable>::value); + +MDSPAN_STATIC_TEST(std::is_constructible::mapping, LS1>::value); +MDSPAN_STATIC_TEST(std::is_convertible::mapping, LS1>::value); +MDSPAN_STATIC_TEST(std::is_assignable::mapping>::value); + +MDSPAN_STATIC_TEST(std::is_constructible::mapping, LS1>::value); +MDSPAN_STATIC_TEST(std::is_convertible::mapping, LS1>::value); +MDSPAN_STATIC_TEST(std::is_assignable::mapping>::value); From da350bba2023282fb7a4db67bdc97fc8c6ced2bc Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 19 Jan 2026 11:49:56 -0500 Subject: [PATCH 2/4] add padded layouts to explicit clause in strided layout converting constructor --- include/experimental/__p0009_bits/layout_stride.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/experimental/__p0009_bits/layout_stride.hpp b/include/experimental/__p0009_bits/layout_stride.hpp index c1a31513..0a3e6e97 100644 --- a/include/experimental/__p0009_bits/layout_stride.hpp +++ b/include/experimental/__p0009_bits/layout_stride.hpp @@ -20,6 +20,7 @@ #include "trait_backports.hpp" #include "compressed_pair.hpp" #include "utility.hpp" +#include "../__p2642_bits/layout_padded_fwd.hpp" #if !defined(MDSPAN_IMPL_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) # include "no_unique_address.hpp" @@ -441,7 +442,9 @@ struct layout_stride { !(std::is_convertible::value && (detail::is_mapping_of || detail::is_mapping_of || - detail::is_mapping_of)) + detail::is_mapping_of || + MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::is_layout_left_padded_mapping::value || + MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::is_layout_right_padded_mapping::value)) ) // needs two () due to comma MDSPAN_INLINE_FUNCTION MDSPAN_IMPL_CONSTEXPR_14 mapping(StridedLayoutMapping const& other) noexcept // NOLINT(google-explicit-constructor) From 57368578671d330a114b4fd76f35b29a8eb1e4f8 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 19 Jan 2026 11:58:21 -0500 Subject: [PATCH 3/4] don't check padded layout to strided layout conversion in < C++17 --- compilation_tests/ctest_layout_convertible.cpp | 2 ++ include/experimental/__p0009_bits/layout_stride.hpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/compilation_tests/ctest_layout_convertible.cpp b/compilation_tests/ctest_layout_convertible.cpp index fc7a0b3f..082e00bc 100644 --- a/compilation_tests/ctest_layout_convertible.cpp +++ b/compilation_tests/ctest_layout_convertible.cpp @@ -103,6 +103,7 @@ MDSPAN_STATIC_TEST(std::is_constructible, LS1 MDSPAN_STATIC_TEST(std::is_convertible, LS1>::value); MDSPAN_STATIC_TEST(std::is_assignable>::value); +#if MDSPAN_HAS_CXX_17 MDSPAN_STATIC_TEST(std::is_constructible::mapping, LS1>::value); MDSPAN_STATIC_TEST(std::is_convertible::mapping, LS1>::value); MDSPAN_STATIC_TEST(std::is_assignable::mapping>::value); @@ -110,3 +111,4 @@ MDSPAN_STATIC_TEST(std::is_assignable::mapping, LS1>::value); MDSPAN_STATIC_TEST(std::is_convertible::mapping, LS1>::value); MDSPAN_STATIC_TEST(std::is_assignable::mapping>::value); +#endif diff --git a/include/experimental/__p0009_bits/layout_stride.hpp b/include/experimental/__p0009_bits/layout_stride.hpp index 0a3e6e97..e4d5e79c 100644 --- a/include/experimental/__p0009_bits/layout_stride.hpp +++ b/include/experimental/__p0009_bits/layout_stride.hpp @@ -443,7 +443,7 @@ struct layout_stride { (detail::is_mapping_of || detail::is_mapping_of || detail::is_mapping_of || - MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::is_layout_left_padded_mapping::value || + MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::is_layout_left_padded_mapping::value || // Don't need to guard for C++14 as this isn't compiled in < C++20 MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::is_layout_right_padded_mapping::value)) ) // needs two () due to comma MDSPAN_INLINE_FUNCTION MDSPAN_IMPL_CONSTEXPR_14 From fc8bc885e4f8ee62bc7ff1271d0c83303eb2804e Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Wed, 28 Jan 2026 10:00:08 -0500 Subject: [PATCH 4/4] address review --- compilation_tests/ctest_layout_convertible.cpp | 10 +++++----- include/experimental/__p0009_bits/layout_stride.hpp | 7 +++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/compilation_tests/ctest_layout_convertible.cpp b/compilation_tests/ctest_layout_convertible.cpp index 082e00bc..935085db 100644 --- a/compilation_tests/ctest_layout_convertible.cpp +++ b/compilation_tests/ctest_layout_convertible.cpp @@ -91,24 +91,24 @@ MDSPAN_STATIC_TEST( !std::is_constructible>::value ); -MDSPAN_STATIC_TEST(std::is_constructible, LS1>::value); +MDSPAN_STATIC_TEST(std::is_constructible>::value); MDSPAN_STATIC_TEST(std::is_convertible, LS1>::value); MDSPAN_STATIC_TEST(std::is_assignable>::value); -MDSPAN_STATIC_TEST(std::is_constructible, LS1>::value); +MDSPAN_STATIC_TEST(std::is_constructible>::value); MDSPAN_STATIC_TEST(std::is_convertible, LS1>::value); MDSPAN_STATIC_TEST(std::is_assignable>::value); -MDSPAN_STATIC_TEST(std::is_constructible, LS1>::value); +MDSPAN_STATIC_TEST(std::is_constructible>::value); MDSPAN_STATIC_TEST(std::is_convertible, LS1>::value); MDSPAN_STATIC_TEST(std::is_assignable>::value); #if MDSPAN_HAS_CXX_17 -MDSPAN_STATIC_TEST(std::is_constructible::mapping, LS1>::value); +MDSPAN_STATIC_TEST(std::is_constructible::mapping>::value); MDSPAN_STATIC_TEST(std::is_convertible::mapping, LS1>::value); MDSPAN_STATIC_TEST(std::is_assignable::mapping>::value); -MDSPAN_STATIC_TEST(std::is_constructible::mapping, LS1>::value); +MDSPAN_STATIC_TEST(std::is_constructible::mapping>::value); MDSPAN_STATIC_TEST(std::is_convertible::mapping, LS1>::value); MDSPAN_STATIC_TEST(std::is_assignable::mapping>::value); #endif diff --git a/include/experimental/__p0009_bits/layout_stride.hpp b/include/experimental/__p0009_bits/layout_stride.hpp index e4d5e79c..2227f230 100644 --- a/include/experimental/__p0009_bits/layout_stride.hpp +++ b/include/experimental/__p0009_bits/layout_stride.hpp @@ -20,7 +20,10 @@ #include "trait_backports.hpp" #include "compressed_pair.hpp" #include "utility.hpp" + +#if MDSPAN_HAS_CXX_17 #include "../__p2642_bits/layout_padded_fwd.hpp" +#endif #if !defined(MDSPAN_IMPL_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) # include "no_unique_address.hpp" @@ -442,9 +445,9 @@ struct layout_stride { !(std::is_convertible::value && (detail::is_mapping_of || detail::is_mapping_of || - detail::is_mapping_of || MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::is_layout_left_padded_mapping::value || // Don't need to guard for C++14 as this isn't compiled in < C++20 - MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::is_layout_right_padded_mapping::value)) + MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::is_layout_right_padded_mapping::value || + detail::is_mapping_of)) ) // needs two () due to comma MDSPAN_INLINE_FUNCTION MDSPAN_IMPL_CONSTEXPR_14 mapping(StridedLayoutMapping const& other) noexcept // NOLINT(google-explicit-constructor)