1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03, c++11, c++14, c++17
10
11#include <atomic>
12#include <type_traits>
13
14#include "test_macros.h"
15
16template <typename T>
17constexpr bool test() {
18 [[maybe_unused]] constexpr T a;
19 static_assert(std::is_nothrow_constructible_v<T>);
20 ASSERT_NOEXCEPT(T{});
21 return true;
22}
23
24struct throwing {
25 throwing() {}
26};
27
28struct trivial {
29 int a;
30};
31
32void test() {
33 static_assert(test<std::atomic<bool>>());
34 static_assert(test<std::atomic<int>>());
35 static_assert(test<std::atomic<int*>>());
36 static_assert(test<std::atomic<trivial>>());
37 static_assert(test<std::atomic_flag>());
38
39 static_assert(!std::is_nothrow_constructible_v<std::atomic<throwing>>);
40 ASSERT_NOT_NOEXCEPT(std::atomic<throwing>{});
41}
42

source code of libcxx/test/std/atomics/atomics.types.generic/constexpr_noexcept.compile.pass.cpp