[libcxx-commits] [libcxx] [libc++] Implement C++20 atomic_ref (PR #76647)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 7 13:35:05 PDT 2024
================
@@ -0,0 +1,37 @@
+//
+// 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
+
+// static constexpr size_t required_alignment;
+
+#include <atomic>
+#include <cassert>
+
+template <typename T>
+constexpr void check_required_alignment() {
+ assert(std::atomic_ref<T>::required_alignment >= alignof(T));
----------------
ldionne wrote:
Very pedantic, but let's do
```
decltype(auto) std::same_as<std::size_t> result = std::atomic_ref<T>::required_alignment;
```
Otherwise technically this could be a custom type that overloads `operator>=`. Twisted minds!
https://github.com/llvm/llvm-project/pull/76647
More information about the libcxx-commits
mailing list