From 134d60906207b65f1431cf3fd20f6934e1ed1097 Mon Sep 17 00:00:00 2001 From: Christian Trott Date: Tue, 10 Oct 2023 13:08:33 -0600 Subject: [PATCH] [libc++][mdspan] Fix extents CTAD extents CTAD was requiring default constructibility of the extent arguments due to the way we implemented a pack expansion. This requirement is not in the standard. Reported in issue #68671 https://github.com/llvm/llvm-project/issues/68671 by @hewillk. Fixes #68671 --- libcxx/include/__mdspan/extents.h | 2 +- .../std/containers/views/mdspan/extents/ctad.pass.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libcxx/include/__mdspan/extents.h b/libcxx/include/__mdspan/extents.h index a510220d4096a2..f6bcd940ee6077 100644 --- a/libcxx/include/__mdspan/extents.h +++ b/libcxx/include/__mdspan/extents.h @@ -456,7 +456,7 @@ using dextents = typename __mdspan_detail::__make_dextents<_IndexType, _Rank>::t // Deduction guide for extents template -extents(_IndexTypes...) -> extents; +extents(_IndexTypes...) -> extents; namespace __mdspan_detail { diff --git a/libcxx/test/std/containers/views/mdspan/extents/ctad.pass.cpp b/libcxx/test/std/containers/views/mdspan/extents/ctad.pass.cpp index 2a3da30bb93660..3fc7c707f036ab 100644 --- a/libcxx/test/std/containers/views/mdspan/extents/ctad.pass.cpp +++ b/libcxx/test/std/containers/views/mdspan/extents/ctad.pass.cpp @@ -21,6 +21,13 @@ #include "../ConvertibleToIntegral.h" #include "test_macros.h" +struct NoDefaultCtorIndex { + size_t value; + constexpr NoDefaultCtorIndex() = delete; + constexpr NoDefaultCtorIndex(size_t val) : value(val){}; + constexpr operator size_t() const noexcept { return value; } +}; + template constexpr void test(E e, Expected expected) { ASSERT_SAME_TYPE(E, Expected); @@ -35,6 +42,7 @@ constexpr bool test() { test(std::extents(1, 2u), std::extents(1, 2u)); test(std::extents(1, 2u, 3, 4, 5, 6, 7, 8, 9), std::extents(1, 2u, 3, 4, 5, 6, 7, 8, 9)); + test(std::extents(NoDefaultCtorIndex{1}, NoDefaultCtorIndex{2}), std::extents(1, 2)); return true; }