[libcxx-commits] [libcxx] [libc++][test] Use `LIBCPP_STATIC_ASSERT` for `std::__mdspan_detail` (PR #73436)

Stephan T. Lavavej via libcxx-commits libcxx-commits at lists.llvm.org
Sun Nov 26 02:41:59 PST 2023


https://github.com/StephanTLavavej created https://github.com/llvm/llvm-project/pull/73436

Found while running libc++'s test suite against MSVC's STL.

`libcxx/test/std` should be portable, so these lines checking `std::__mdspan_detail` machinery should be using `LIBCPP_STATIC_ASSERT`.

I checked for other occurrences and these appear to be the only ones which have appeared since our last libc++ test suite update.

>From 3a0e27ffa05190607a4d826a32409fc43042a9c9 Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Fri, 24 Nov 2023 13:39:49 -0800
Subject: [PATCH] Use `LIBCPP_STATIC_ASSERT` for `std::__mdspan_detail`.

---
 .../views/mdspan/layout_left/static_requirements.pass.cpp       | 2 +-
 .../views/mdspan/layout_right/static_requirements.pass.cpp      | 2 +-
 .../views/mdspan/layout_stride/static_requirements.pass.cpp     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libcxx/test/std/containers/views/mdspan/layout_left/static_requirements.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_left/static_requirements.pass.cpp
index b74d129946d40dd..366498803a2ded5 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_left/static_requirements.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_left/static_requirements.pass.cpp
@@ -87,7 +87,7 @@
 template <class M, size_t... Idxs>
 void test_mapping_requirements(std::index_sequence<Idxs...>) {
   using E = typename M::extents_type;
-  static_assert(std::__mdspan_detail::__is_extents_v<E>);
+  LIBCPP_STATIC_ASSERT(std::__mdspan_detail::__is_extents_v<E>);
   static_assert(std::is_copy_constructible_v<M>);
   static_assert(std::is_nothrow_move_constructible_v<M>);
   static_assert(std::is_nothrow_move_assignable_v<M>);
diff --git a/libcxx/test/std/containers/views/mdspan/layout_right/static_requirements.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_right/static_requirements.pass.cpp
index 33e736b15029c7d..d460f1a5dbc468a 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_right/static_requirements.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_right/static_requirements.pass.cpp
@@ -87,7 +87,7 @@
 template <class M, size_t... Idxs>
 void test_mapping_requirements(std::index_sequence<Idxs...>) {
   using E = typename M::extents_type;
-  static_assert(std::__mdspan_detail::__is_extents_v<E>);
+  LIBCPP_STATIC_ASSERT(std::__mdspan_detail::__is_extents_v<E>);
   static_assert(std::is_copy_constructible_v<M>);
   static_assert(std::is_nothrow_move_constructible_v<M>);
   static_assert(std::is_nothrow_move_assignable_v<M>);
diff --git a/libcxx/test/std/containers/views/mdspan/layout_stride/static_requirements.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_stride/static_requirements.pass.cpp
index 112f4b9e5a04033..b56d0087260d1fc 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_stride/static_requirements.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_stride/static_requirements.pass.cpp
@@ -87,7 +87,7 @@
 template <class M, size_t... Idxs>
 void test_mapping_requirements(std::index_sequence<Idxs...>) {
   using E = typename M::extents_type;
-  static_assert(std::__mdspan_detail::__is_extents_v<E>);
+  LIBCPP_STATIC_ASSERT(std::__mdspan_detail::__is_extents_v<E>);
   static_assert(std::is_copy_constructible_v<M>);
   static_assert(std::is_nothrow_move_constructible_v<M>);
   static_assert(std::is_nothrow_move_assignable_v<M>);



More information about the libcxx-commits mailing list