return __se;
}
+ template<size_t _OtherRank, typename _GetOtherExtent>
+ static constexpr bool
+ _S_is_compatible_extents(_GetOtherExtent __get_extent) noexcept
+ {
+ if constexpr (_OtherRank == _S_rank)
+ for (size_t __i = 0; __i < _S_rank; ++__i)
+ if (_Extents[__i] != dynamic_extent
+ && !cmp_equal(_Extents[__i], _S_int_cast(__get_extent(__i))))
+ return false;
+ return true;
+ }
+
template<size_t _OtherRank, typename _GetOtherExtent>
constexpr void
_M_init_dynamic_extents(_GetOtherExtent __get_extent) noexcept
{
+ __glibcxx_assert(_S_is_compatible_extents<_OtherRank>(__get_extent));
for (size_t __i = 0; __i < _S_rank_dynamic; ++__i)
{
size_t __di = __i;
std::extents<char, 1> e2; // { dg-error "from here" }
std::extents<bool, 1> e3; // { dg-error "from here" }
std::extents<double, 1> e4; // { dg-error "from here" }
+
// { dg-prune-output "dynamic or representable as IndexType" }
// { dg-prune-output "signed or unsigned integer" }
// { dg-prune-output "invalid use of incomplete type" }
+// { dg-prune-output "non-constant condition for static assertion" }
--- /dev/null
+// { dg-do compile { target c++23 } }
+#include<mdspan>
+
+#include <cstdint>
+
+constexpr size_t dyn = std::dynamic_extent;
+
+constexpr bool
+test_dyn2sta_extents_mismatch_00()
+{
+ auto e0 = std::extents<int, dyn>{1};
+ [[maybe_unused]] auto e1 = std::extents<int, 2>{e0}; // { dg-error "expansion of" }
+ return true;
+}
+static_assert(test_dyn2sta_extents_mismatch_00()); // { dg-error "expansion of" }
+
+constexpr bool
+test_dyn2sta_extents_mismatch_01()
+{
+ [[maybe_unused]] auto e = std::extents<int, 1, dyn>{2, 2}; // { dg-error "expansion of" }
+ return true;
+}
+static_assert(test_dyn2sta_extents_mismatch_01()); // { dg-error "expansion of" }
+
+constexpr bool
+test_dyn2sta_extents_mismatch_02()
+{
+ std::array<int, 2> exts{2, 2};
+ [[maybe_unused]] auto e = std::extents<int, 1, dyn>{exts}; // { dg-error "expansion of" }
+ return true;
+}
+static_assert(test_dyn2sta_extents_mismatch_02()); // { dg-error "expansion of" }
+
+// { dg-prune-output "non-constant condition for static assertion" }
+// { dg-prune-output "__glibcxx_assert" }