[PATCH v2 1/5] libstdc++: Refactor layout mapping tests to use a concept.
Tomasz Kaminski
tkaminsk@redhat.com
Thu Sep 11 11:57:07 GMT 2025
On Thu, Sep 11, 2025 at 1:47 PM Luc Grosheintz <luc.grosheintz@gmail.com>
wrote:
> The layout mapping test include a check that applies if is_exhaustive is
> static. This commit introduces a concept to check if is_exhaustive is a
> static member function that's compatible with the upcoming
> layout_left_padded.
>
> libstdc++-v3/ChangeLog:
>
> * testsuite/23_containers/mdspan/layouts/mapping.cc
> (has_static_is_exhaustive): New concept.
> (test_mapping_properties): Update test.
>
> Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
> ---
>
LGTM.
> .../testsuite/23_containers/mdspan/layouts/mapping.cc | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git
> a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/mapping.cc
> b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/mapping.cc
> index 58bce514435..ee902a3cc05 100644
> --- a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/mapping.cc
> +++ b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/mapping.cc
> @@ -7,6 +7,15 @@
>
> constexpr size_t dyn = std::dynamic_extent;
>
> +template<typename Mapping>
> + concept has_static_is_exhaustive = requires
> + {
> + { Mapping::is_exhaustive() } -> std::same_as<bool>;
> + };
> +
>
> +static_assert(has_static_is_exhaustive<std::layout_right::mapping<std::extents<int>>>);
>
> +static_assert(!has_static_is_exhaustive<std::layout_stride::mapping<std::extents<int>>>);
> +
> template<typename Layout, typename Extents>
> constexpr bool
> test_mapping_properties()
> @@ -32,7 +41,7 @@ template<typename Layout, typename Extents>
>
> static_assert(M::is_always_unique() && M::is_unique());
> static_assert(M::is_always_strided() && M::is_strided());
> - if constexpr (!std::is_same_v<Layout, std::layout_stride>)
> + if constexpr (has_static_is_exhaustive<M>)
> static_assert(M::is_always_exhaustive() && M::is_exhaustive());
> return true;
> }
> --
> 2.50.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20250911/98f9ea47/attachment.htm>
More information about the Libstdc++
mailing list