[libcxx-commits] [libcxx] [libc++][mdspan][test] Correct `mapping::operator()` constraint tests (PR #201061)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 2 01:42:23 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: eiytoq (eiytoq)

<details>
<summary>Changes</summary>

The previous requires-expression only checked that `std::is_same_v<...>` was a well-formed expression, so the test would pass even when the result was false.

---
Full diff: https://github.com/llvm/llvm-project/pull/201061.diff


3 Files Affected:

- (modified) libcxx/test/std/containers/views/mdspan/layout_left/index_operator.pass.cpp (+1-2) 
- (modified) libcxx/test/std/containers/views/mdspan/layout_right/index_operator.pass.cpp (+1-2) 
- (modified) libcxx/test/std/containers/views/mdspan/layout_stride/index_operator.pass.cpp (+1-2) 


``````````diff
diff --git a/libcxx/test/std/containers/views/mdspan/layout_left/index_operator.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_left/index_operator.pass.cpp
index 55d9539d8c63f..15c130acc5ca5 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_left/index_operator.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_left/index_operator.pass.cpp
@@ -27,7 +27,6 @@
 #include <cstddef>
 #include <cstdint>
 #include <mdspan>
-#include <type_traits>
 
 #include "test_macros.h"
 
@@ -35,7 +34,7 @@
 
 template <class Mapping, class... Indices>
 concept operator_constraints = requires(Mapping m, Indices... idxs) {
-  { std::is_same_v<decltype(m(idxs...)), typename Mapping::index_type> };
+  { m(idxs...) } noexcept -> std::same_as<typename Mapping::index_type>;
 };
 
 template <class Mapping, class... Indices>
diff --git a/libcxx/test/std/containers/views/mdspan/layout_right/index_operator.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_right/index_operator.pass.cpp
index 4623af7fb5b76..7f6876d4e4a1b 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_right/index_operator.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_right/index_operator.pass.cpp
@@ -27,7 +27,6 @@
 #include <cstddef>
 #include <cstdint>
 #include <mdspan>
-#include <type_traits>
 
 #include "test_macros.h"
 
@@ -35,7 +34,7 @@
 
 template <class Mapping, class... Indices>
 concept operator_constraints = requires(Mapping m, Indices... idxs) {
-  { std::is_same_v<decltype(m(idxs...)), typename Mapping::index_type> };
+  { m(idxs...) } noexcept -> std::same_as<typename Mapping::value_type>;
 };
 
 template <class Mapping, class... Indices>
diff --git a/libcxx/test/std/containers/views/mdspan/layout_stride/index_operator.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_stride/index_operator.pass.cpp
index b483885049a7b..02b804c98254b 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_stride/index_operator.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_stride/index_operator.pass.cpp
@@ -27,7 +27,6 @@
 #include <array>
 #include <cassert>
 #include <cstdint>
-#include <type_traits>
 
 #include "test_macros.h"
 
@@ -35,7 +34,7 @@
 
 template <class Mapping, class... Indices>
 concept operator_constraints = requires(Mapping m, Indices... idxs) {
-  { std::is_same_v<decltype(m(idxs...)), typename Mapping::index_type> };
+  { m(idxs...) } noexcept -> std::same_as<typename Mapping::value_type>;
 };
 
 template <class Mapping, class... Indices>

``````````

</details>


https://github.com/llvm/llvm-project/pull/201061


More information about the libcxx-commits mailing list