[libcxx-commits] [libcxx] [libc++] Partially implement P2642R6: Padded mdspan layouts (PR #187873)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Mar 21 11:00:00 PDT 2026
================
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++26
+// UNSUPPORTED: libcpp-hardening-mode=none
+// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing
+
+// <mdspan>
+
+// constexpr mapping(const layout_stride::mapping<OtherExtents>& other);
+// constexpr mapping(const LayoutRightPaddedMapping& other);
+
+#include <array>
+#include <cstddef>
+#include <mdspan>
+
+#include "check_assertion.h"
+
+int main() {
+#if 0
+ {
+ using Src = std::layout_right_padded<std::dynamic_extent>::mapping<std::extents<uint32_t, 0, 1>>;
+ using Dst = std::layout_right_padded<std::dynamic_extent>::mapping<std::extents<uint8_t, 0, 1>>;
+
+ Src src(std::extents<uint32_t, 0, 1>(), 256);
+
+ TEST_LIBCPP_ASSERT_FAILURE(
+ Dst(src),
+ "layout_right_padded::mapping from layout_right_padded ctor: source padded stride must be "
+ "representable as index_type.");
+ }
+
+ {
+ using Src = std::layout_stride::mapping<std::extents<uint32_t, 0, 1>>;
+ using Dst = std::layout_right_padded<std::dynamic_extent>::mapping<std::extents<uint8_t, 0, 1>>;
+
+ Src src(std::extents<uint32_t, 0, 1>(), std::array<uint32_t, 2>{256, 1});
+
+ TEST_LIBCPP_ASSERT_FAILURE(
+ Dst(src),
+ "layout_right_padded::mapping from layout_stride ctor: source padded stride must be "
+ "representable as index_type.");
+ }
+#endif
----------------
eiytoq wrote:
Same as above.
https://github.com/llvm/llvm-project/pull/187873
More information about the libcxx-commits
mailing list