Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/atomic/ATOMIC FLAG INIT"

From cppreference.com
< cpp‎ | atomic
(clarifications from c++14)
m (= in a macro)
Line 8: Line 8:
 
{{dcl end}}
 
{{dcl end}}
  
Defines the expression which can be used to initialize {{lc|std::atomic_flag}} to clear (false) state with the statement {{c|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.
+
Defines the expression which can be used to initialize {{lc|std::atomic_flag}} to clear (false) state with the statement {{c|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.
  
 
===Example===
 
===Example===

Revision as of 12:40, 9 November 2013

 
 
 
Defined in header <atomic>
#define ATOMIC_FLAG_INIT /* implementation-defined */

Defines the expression 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.

Example

#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
}

See also

the lock-free boolean atomic type
(class) [edit]