[libcxx-commits] [libcxx] [libc++] P3029R1: Better `mdspan`'s CTAD - `std::extents` (PR #89015)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sat Apr 20 10:30:53 PDT 2024


================
@@ -455,8 +455,15 @@ template <class _IndexType, size_t _Rank>
 using dextents = typename __mdspan_detail::__make_dextents<_IndexType, _Rank>::type;
 
 // Deduction guide for extents
+#  if _LIBCPP_STD_VER >= 26
 template <class... _IndexTypes>
-extents(_IndexTypes...) -> extents<size_t, size_t(((void)sizeof(_IndexTypes), dynamic_extent))...>;
+  requires(is_convertible_v<_IndexTypes, size_t> && ...)
+explicit extents(_IndexTypes...) -> extents<size_t, __maybe_static_ext<_IndexTypes>...>;
+#  else
+template <class... _IndexTypes>
+  requires(is_convertible_v<_IndexTypes, size_t> && ...)
+explicit extents(_IndexTypes...) -> extents<size_t, size_t(((void)sizeof(_IndexTypes), dynamic_extent))...>;
----------------
mordante wrote:

Is this really correct? The original wording in the paper seems to be
```
Remarks: The deduced type is dextents<size_t, sizeof...(Integrals)>
                             ^                      ^^^
```


https://github.com/llvm/llvm-project/pull/89015


More information about the libcxx-commits mailing list