This header provides atomic operations, in particular, it's a part of the concurrency support library.
Each instantiation and full specialization of the std::atomic template defines an atomic type. If one thread writes to an atomic object while another thread reads from it, the behavior is well-defined (see memory model for details on data races).
Constructs a new atomic variable. ... 2) Initializes the underlying object with desired. The initialization is not atomic. 3) Atomic variables are not CopyConstructible.
Types The standard library offers convenience typedefs for the core language atomic types.
C++ includes built-in support for threads, atomic operations, mutual exclusion, condition variables, and futures.
Each atomic object has its own associated modification order, which is a total order of modifications made to that object. If, from some thread's point of view, modification A of some atomic M happens-before modification B of the same atomic M, then in the modification order of M, A occurs before B.
1 2 3 4Synopsis 4.1Class template std::atomic 4.2Specializations of std::atomic for integral types 4.3Specializations of std::atomic for floating-point types 4.4Specializations of std::atomic for pointer types 4.5Class template std::atomic_ref 4.6Specializations of std::atomic_ref for integral types 4.7Specializations of std::atomic_ref for floating-point types 4.8Specializations of std ...
operator++(int) and operator--(int) return the value of the atomic variable before the modification. Formally, the value immediately preceding the effects of this function in the modification order of *this.
Initializes the default-constructed atomic object obj with the value desired. The function is not atomic: concurrent access from another thread, even through an atomic operation, is a data race. If obj was not default-constructed, or this function is called twice on the same obj, the behavior is undefined.