[libcxx-commits] [libcxx] [libc++] Implement C++20 atomic_ref (PR #76647)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Feb 5 11:30:47 PST 2024
================
@@ -0,0 +1,34 @@
+//
+// 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>
+
+template <typename T>
+void checkRequiredAlignment() {
+ static_assert(std::atomic_ref<T>::required_alignment >= alignof(T));
+}
----------------
ldionne wrote:
I think I would do this instead:
```c++
template <class T>
constexpr void check_required_alignment() {
assert(std::atomic_ref<T>::required_alignment >= alignof(T));
}
```
And then do the usual trick where we return a `bool` in a `static_assert`. That way we actually reference `required_alignment` at runtime too.
https://github.com/llvm/llvm-project/pull/76647
More information about the libcxx-commits
mailing list