[libcxx-commits] [libcxx] [libc++] Fix mdspan layout_left / layout_right conversion rank constraint (PR #192847)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Apr 19 05:44:04 PDT 2026


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

Fixes: #158316

>From c97887d83b701e19807e2ec877c97b7ad52bfbd7 Mon Sep 17 00:00:00 2001
From: eiytoq <eiytoq at outlook.com>
Date: Sun, 19 Apr 2026 20:41:23 +0800
Subject: [PATCH] fix

---
 libcxx/include/__mdspan/layout_left.h  | 2 +-
 libcxx/include/__mdspan/layout_right.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/__mdspan/layout_left.h b/libcxx/include/__mdspan/layout_left.h
index fb1b59555b254..ce4e83fe7a8ee 100644
--- a/libcxx/include/__mdspan/layout_left.h
+++ b/libcxx/include/__mdspan/layout_left.h
@@ -94,7 +94,7 @@ class layout_left::mapping {
   }
 
   template <class _OtherExtents>
-    requires(is_constructible_v<extents_type, _OtherExtents> && _OtherExtents::rank() <= 1)
+    requires(extents_type::rank() <= 1 && is_constructible_v<extents_type, _OtherExtents>)
   _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherExtents, extents_type>)
       mapping(const layout_right::mapping<_OtherExtents>& __other) noexcept
       : __extents_(__other.extents()) {
diff --git a/libcxx/include/__mdspan/layout_right.h b/libcxx/include/__mdspan/layout_right.h
index 7cb828022ea8e..16fb10bb46145 100644
--- a/libcxx/include/__mdspan/layout_right.h
+++ b/libcxx/include/__mdspan/layout_right.h
@@ -94,7 +94,7 @@ class layout_right::mapping {
   }
 
   template <class _OtherExtents>
-    requires(is_constructible_v<extents_type, _OtherExtents> && _OtherExtents::rank() <= 1)
+    requires(extents_type::rank() <= 1 && is_constructible_v<extents_type, _OtherExtents>)
   _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherExtents, extents_type>)
       mapping(const layout_left::mapping<_OtherExtents>& __other) noexcept
       : __extents_(__other.extents()) {



More information about the libcxx-commits mailing list