[libcxx-commits] [libcxx] c838322 - [libc++] LWG4511: Inconsistency between the deduction guide of `std::mdspan` taking `(data_handle_type, mapping_type, accessor_type)` and the corresponding constructor (#191950)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Apr 14 01:16:14 PDT 2026


Author: eiytoq
Date: 2026-04-14T16:16:09+08:00
New Revision: c83832275136474dd9ad0a34c8e0e764a2853cc0

URL: https://github.com/llvm/llvm-project/commit/c83832275136474dd9ad0a34c8e0e764a2853cc0
DIFF: https://github.com/llvm/llvm-project/commit/c83832275136474dd9ad0a34c8e0e764a2853cc0.diff

LOG: [libc++] LWG4511: Inconsistency between the deduction guide of `std::mdspan` taking `(data_handle_type, mapping_type, accessor_type)` and the corresponding constructor (#191950)

No functional change; this only removes a redundant const qualifier.

Fixes: #189860

Added: 
    

Modified: 
    libcxx/docs/Status/Cxx2cIssues.csv
    libcxx/include/__mdspan/mdspan.h
    libcxx/include/mdspan
    libcxx/test/std/containers/views/mdspan/mdspan/deduction.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/Status/Cxx2cIssues.csv b/libcxx/docs/Status/Cxx2cIssues.csv
index a4afad4efa884..1653562724982 100644
--- a/libcxx/docs/Status/Cxx2cIssues.csv
+++ b/libcxx/docs/Status/Cxx2cIssues.csv
@@ -315,7 +315,7 @@
 "`LWG4504 <https://wg21.link/LWG4504>`__","Wording problem in ``{simple_}counting_scope``","2026-03 (Croydon)","","","`#189857 <https://github.com/llvm/llvm-project/issues/189857>`__",""
 "`LWG4506 <https://wg21.link/LWG4506>`__","``source_location`` is explicitly unspecified if is constexpr or not","2026-03 (Croydon)","","","`#189858 <https://github.com/llvm/llvm-project/issues/189858>`__",""
 "`LWG4510 <https://wg21.link/LWG4510>`__","Ambiguity of ``std::ranges::advance`` and ``std::ranges::next`` when the 
diff erence type is also a sentinel type","2026-03 (Croydon)","","","`#189859 <https://github.com/llvm/llvm-project/issues/189859>`__",""
-"`LWG4511 <https://wg21.link/LWG4511>`__","Inconsistency between the deduction guide of ``std::mdspan`` taking ``(data_handle_type, mapping_type, accessor_type)`` and the corresponding constructor","2026-03 (Croydon)","","","`#189860 <https://github.com/llvm/llvm-project/issues/189860>`__",""
+"`LWG4511 <https://wg21.link/LWG4511>`__","Inconsistency between the deduction guide of ``std::mdspan`` taking ``(data_handle_type, mapping_type, accessor_type)`` and the corresponding constructor","2026-03 (Croydon)","|Complete|","18","`#189860 <https://github.com/llvm/llvm-project/issues/189860>`__",""
 "`LWG4512 <https://wg21.link/LWG4512>`__","The ``system_encoded_string()`` and ``generic_system_encoded_string()`` member functions of ``std::filesystem::path`` are misnamed","2026-03 (Croydon)","","","`#189861 <https://github.com/llvm/llvm-project/issues/189861>`__",""
 "`LWG4514 <https://wg21.link/LWG4514>`__","Missing absolute value of ``init`` in ``vector_two_norm`` and ``matrix_frob_norm``","2026-03 (Croydon)","","","`#189862 <https://github.com/llvm/llvm-project/issues/189862>`__",""
 "`LWG4517 <https://wg21.link/LWG4517>`__","``data_member_spec`` should throw for *cv*-qualified unnamed bit-fields","2026-03 (Croydon)","","","`#189863 <https://github.com/llvm/llvm-project/issues/189863>`__",""

diff  --git a/libcxx/include/__mdspan/mdspan.h b/libcxx/include/__mdspan/mdspan.h
index 024c1002b1a09..54685b56a76ff 100644
--- a/libcxx/include/__mdspan/mdspan.h
+++ b/libcxx/include/__mdspan/mdspan.h
@@ -313,7 +313,7 @@ mdspan(_ElementType*, const _MappingType&)
     -> mdspan<_ElementType, typename _MappingType::extents_type, typename _MappingType::layout_type>;
 
 template <class _MappingType, class _AccessorType>
-mdspan(const typename _AccessorType::data_handle_type, const _MappingType&, const _AccessorType&)
+mdspan(typename _AccessorType::data_handle_type, const _MappingType&, const _AccessorType&)
     -> mdspan<typename _AccessorType::element_type,
               typename _MappingType::extents_type,
               typename _MappingType::layout_type,

diff  --git a/libcxx/include/mdspan b/libcxx/include/mdspan
index 618f6927bf7a1..d46f87cb0f014 100644
--- a/libcxx/include/mdspan
+++ b/libcxx/include/mdspan
@@ -431,7 +431,7 @@ namespace std {
                 typename MappingType::layout_type>;
 
   template<class MappingType, class AccessorType>
-    mdspan(const typename AccessorType::data_handle_type&, const MappingType&,
+    mdspan(typename AccessorType::data_handle_type, const MappingType&,
            const AccessorType&)
       -> mdspan<typename AccessorType::element_type, typename MappingType::extents_type,
                 typename MappingType::layout_type, AccessorType>;

diff  --git a/libcxx/test/std/containers/views/mdspan/mdspan/deduction.pass.cpp b/libcxx/test/std/containers/views/mdspan/mdspan/deduction.pass.cpp
index 8b4d24d2a398d..762841016e29e 100644
--- a/libcxx/test/std/containers/views/mdspan/mdspan/deduction.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/mdspan/deduction.pass.cpp
@@ -46,7 +46,7 @@
 //                typename MappingType::layout_type>;
 //
 //  template<class MappingType, class AccessorType>
-//    mdspan(const typename AccessorType::data_handle_type&, const MappingType&,
+//    mdspan(typename AccessorType::data_handle_type, const MappingType&,
 //           const AccessorType&)
 //      -> mdspan<typename AccessorType::element_type, typename MappingType::extents_type,
 //                typename MappingType::layout_type, AccessorType>;
@@ -167,6 +167,11 @@ constexpr bool test() {
   float a[12];
   ASSERT_SAME_TYPE(decltype(std::mdspan(a)), std::mdspan<float, std::extents<size_t, 12>>);
 
+  float* volatile p = a;
+  ASSERT_SAME_TYPE(decltype(std::mdspan(
+                       p, std::layout_right::mapping<std::extents<std::size_t, 1>>{}, std::default_accessor<float>{})),
+                   std::mdspan<float, std::extents<std::size_t, 1>, std::layout_right, std::default_accessor<float>>);
+
   return true;
 }
 int main(int, char**) {


        


More information about the libcxx-commits mailing list