[libcxx-commits] [libcxx] [libc++] P3029R1: Better `mdspan`'s CTAD - `std::extents` (PR #89015)
Xiaoyang Liu via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Apr 20 13:24:44 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))...>;
----------------
xiaoyang-sde wrote:
I believe the implementation is equivalent to the wording in the paper. (We can't use `dextents` as the deduced type because the compiler doesn't recognize it as a specialization of `extents`.) For example, `dextents<size_t, 3>` is equivalent to `extents<size_t, dynamic_extent, dynamic_extent, dynamic_extent>`.
https://github.com/llvm/llvm-project/pull/89015
More information about the libcxx-commits
mailing list