[libcxx-commits] [libcxx] [libc++] Implement P2897R7 aligned_accessor: An mdspan accessor expressing pointer over-alignment (PR #122603)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jan 31 13:13:44 PST 2025
================
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <mdspan>
+
+// constexpr reference access(data_handle_type p, size_t i) const noexcept;
+//
+// Effects: Equivalent to: return assume_aligned<byte_alignment>(p)[i];
+
+#include <mdspan>
+#include <cassert>
+#include <cstdint>
+#include <concepts>
+#include <type_traits>
+
+#include "test_macros.h"
+
+#include "../MinimalElementType.h"
+
+template <class T, size_t N>
+constexpr void test_access() {
+ ElementPool<std::remove_const_t<T>, 10 + N> data;
----------------
ldionne wrote:
Given the special requirements of this aligned accessor, I think we would be better off not using `ElementPool` here and instead using a manually-aligned C array. That will make this test work at compile-time. I would encourage you to add a short comment explaining why we ditched `MinimalElementType.h` here.
https://github.com/llvm/llvm-project/pull/122603
More information about the libcxx-commits
mailing list