[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:41:37 PDT 2026


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

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.

>From 830a04c040a0c8ee8eea2d6f051bdd889cba628f Mon Sep 17 00:00:00 2001
From: eiytoq <eiytoq at outlook.com>
Date: Tue, 2 Jun 2026 16:39:24 +0800
Subject: [PATCH] fix

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

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>



More information about the libcxx-commits mailing list