41 lines · cpp
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-exception5//6//===----------------------------------------------------------------------===//7 8// UNSUPPORTED: c++03, c++11, c++14, c++179 10// static constexpr size_t required_alignment;11 12#include <atomic>13#include <cassert>14#include <concepts>15#include <cstddef>16 17template <typename T>18constexpr void check_required_alignment() {19 std::same_as<const std::size_t> decltype(auto) required_alignment = std::atomic_ref<T>::required_alignment;20 assert(required_alignment >= alignof(T));21}22 23constexpr bool test() {24 check_required_alignment<int>();25 check_required_alignment<float>();26 check_required_alignment<int*>();27 struct Empty {};28 check_required_alignment<Empty>();29 struct Trivial {30 int a;31 };32 check_required_alignment<Trivial>();33 return true;34}35 36int main(int, char**) {37 test();38 static_assert(test());39 return 0;40}41