Debian Codegraph @

libcxx/test/std/atomics/atomics.ref/required_alignment.pass.cpp

raw
1 //
2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 //
6 //===----------------------------------------------------------------------===//
7
8 // UNSUPPORTED: c++03, c++11, c++14, c++17
9
10 // static constexpr size_t required_alignment;
11
12 #include <atomic>
13 #include <cassert>
14 #include <concepts>
15
16 template <typename T>
17 constexpr void check_required_alignment() {
18 std::same_as<const std::size_t> decltype(auto) required_alignment = std::atomic_ref<T>::required_alignment;
19 assert(required_alignment >= alignof(T));
20 }
21
22 constexpr bool test() {
23 check_required_alignment<int>();
24 check_required_alignment<float>();
25 check_required_alignment<int*>();
26 struct Empty {};
27 check_required_alignment<Empty>();
28 struct Trivial {
29 int a;
30 };
31 check_required_alignment<Trivial>();
32 return true;
33 }
34
35 int main(int, char**) {
36 test();
37 static_assert(test());
38 return 0;
39 }