Defined in header <atomic> | ||
---|---|---|
#define ATOMIC_FLAG_INIT /* implementation-defined */ | (since C++11) |
Defines the initializer which can be used to initialize std::atomic_flag
to clear (false) state with the statement std::atomic_flag v = ATOMIC_FLAG_INIT;
. It is unspecified if it can be used with other initialization contexts.
If the flag has static storage duration, this initialization is static.
This is the only way to initialize | (until C++20) |
This macro is no longer needed since default constructor of | (since C++20) |
#include <atomic> std::atomic_flag static_flag = ATOMIC_FLAG_INIT; // static initialization, // guaranteed to be available during dynamic initialization of static objects. int main() { std::atomic_flag automatic_flag = ATOMIC_FLAG_INIT; // guaranteed to work // std::atomic_flag another_flag(ATOMIC_FLAG_INIT); // unspecified }
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 3659 | C++20 | ATOMIC_FLAG_INIT was deprecated, but needed in C on some platforms | it is undeprecated |
(C++11) | the lock-free boolean atomic type (class) |
C documentation for ATOMIC_FLAG_INIT |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/atomic/ATOMIC_FLAG_INIT