[libcxx-commits] [libcxx] [libc++] Enable `mdspan::operator[]` constraint tests for AppleClang (PR #192475)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Apr 16 08:26:46 PDT 2026
https://github.com/eiytoq created https://github.com/llvm/llvm-project/pull/192475
Although I couldn't find a corresponding AppleClang release note, this issue appears to be fixed in AppleClang 16.
>From 06865c539e3163aa7fa9bb327a8a617498cc0b57 Mon Sep 17 00:00:00 2001
From: eiytoq <eiytoq at outlook.com>
Date: Thu, 16 Apr 2026 23:23:37 +0800
Subject: [PATCH] [libc++] Enable `mdspan::operator[]` constraint tests for
AppleClang
---
.../mdspan/mdspan/index_operator.pass.cpp | 31 -------------------
1 file changed, 31 deletions(-)
diff --git a/libcxx/test/std/containers/views/mdspan/mdspan/index_operator.pass.cpp b/libcxx/test/std/containers/views/mdspan/mdspan/index_operator.pass.cpp
index 9124bd2314806..c26933e80bfaf 100644
--- a/libcxx/test/std/containers/views/mdspan/mdspan/index_operator.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/mdspan/index_operator.pass.cpp
@@ -39,30 +39,6 @@
#include "../ConvertibleToIntegral.h"
#include "../CustomTestLayouts.h"
-// Apple Clang does not support argument packs as input to operator []
-#ifdef TEST_COMPILER_APPLE_CLANG
-template <class MDS>
-constexpr auto& access(MDS mds) {
- return mds[];
-}
-template <class MDS>
-constexpr auto& access(MDS mds, int64_t i0) {
- return mds[i0];
-}
-template <class MDS>
-constexpr auto& access(MDS mds, int64_t i0, int64_t i1) {
- return mds[i0, i1];
-}
-template <class MDS>
-constexpr auto& access(MDS mds, int64_t i0, int64_t i1, int64_t i2) {
- return mds[i0, i1, i2];
-}
-template <class MDS>
-constexpr auto& access(MDS mds, int64_t i0, int64_t i1, int64_t i2, int64_t i3) {
- return mds[i0, i1, i2, i3];
-}
-#endif
-
template <class MDS, class... Indices>
concept operator_constraints = requires(MDS m, Indices... idxs) {
{ std::is_same_v<decltype(m[idxs...]), typename MDS::reference> };
@@ -84,11 +60,7 @@ template <class MDS, class... Args>
constexpr void iterate(MDS mds, Args... args) {
constexpr int r = static_cast<int>(MDS::extents_type::rank()) - 1 - static_cast<int>(sizeof...(Args));
if constexpr (-1 == r) {
-#ifdef TEST_COMPILER_APPLE_CLANG
- int* ptr1 = &access(mds, args...);
-#else
int* ptr1 = &mds[args...];
-#endif
int* ptr2 = &(mds.accessor().access(mds.data_handle(), mds.mapping()(args...)));
assert(ptr1 == ptr2);
@@ -123,8 +95,6 @@ constexpr void test_layout() {
test_iteration(construct_mapping(Layout(), std::extents<unsigned, 7, 8>()));
test_iteration(construct_mapping(Layout(), std::extents<signed char, D, D, D, D>(1, 1, 1, 1)));
-// TODO(LLVM 20): Enable this once AppleClang is upgraded
-#ifndef TEST_COMPILER_APPLE_CLANG
int data[1];
// Check operator constraint for number of arguments
static_assert(check_operator_constraints(std::mdspan(data, construct_mapping(Layout(), std::extents<int, D>(1))), 0));
@@ -217,7 +187,6 @@ constexpr void test_layout() {
assert(!check_operator_constraints(std::mdspan(data, construct_mapping(Layout(), std::extents<int, D>(1))), s));
}
}
-#endif // TEST_COMPILER_APPLE_CLANG
}
template <class Layout>
More information about the libcxx-commits
mailing list