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// <atomic>
10
11// struct atomic_flag
12
13// atomic_flag() = default;
14
15#include <atomic>
16#include <new>
17#include <cassert>
18
19#include "test_macros.h"
20
21int main(int, char**)
22{
23 std::atomic_flag f;
24 f.clear();
25 assert(f.test_and_set() == 0);
26 {
27 typedef std::atomic_flag A;
28 TEST_ALIGNAS_TYPE(A) char storage[sizeof(A)] = {1};
29 A& zero = *new (storage) A();
30 assert(!zero.test_and_set());
31 zero.~A();
32 }
33
34 return 0;
35}
36

source code of libcxx/test/std/atomics/atomics.flag/default.pass.cpp