Namespaces
Variants

std::atomic_flag:: atomic_flag

From cppreference.net
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
Generic lock management
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
Safe reclamation
Hazard pointers
Atomic types
(C++11)
(C++20)
Initialization of atomic types
(C++11) (deprecated in C++20)
(C++11) (deprecated in C++20)
Memory ordering
(C++11) (deprecated in C++26)
Free functions for atomic operations
Free functions for atomic flags
定义于头文件 <atomic>
(1)
atomic_flag ( ) noexcept = default ;
(C++11 起)
(C++20 前)
constexpr atomic_flag ( ) noexcept ;
(C++20 起)
atomic_flag ( const atomic_flag & ) = delete ;
(2) (C++11 起)

构造一个新的 std::atomic_flag

1) 平凡的默认构造函数,将 std::atomic_flag 初始化为未指定状态。
(C++20 前)
1) std::atomic_flag 初始化为清除状态。
(C++20 起)
2) 复制构造函数被删除; std::atomic_flag 不可复制。

此外, std::atomic_flag 可通过 ATOMIC_FLAG_INIT 表达式进行值初始化以清除状态。对于具有静态 存储期 atomic_flag ,这保证了 静态初始化 :该标志可在静态对象的构造函数中使用。

参见

std::atomic_flag 初始化为 false
(宏常量)