The ATOMIC_VAR_INIT macro
provides a means of initializing an atomic variable to a particular value.
#define ATOMIC_VAR_INIT(value) see description
The macro expands to a token sequence that can be used to initialize one of the standard atomic types with the specified value in an expression of the following form:
std::atomic_type x = ATOMIC_VAR_INIT(val);
The specified value must be compatible with the non-atomic type corresponding to the atomic variable.
e.g.
std::atomic_int i = ATOMIC_VAR_INIT(42); std::string s; std::atomic_address p = ATOMIC_VAR_INIT(&s);
Such initialization is not atomic, and any access by another thread to the variable being initialized that does not happen-after the initialization is a data race and thus undefined behaviour.
Header
#include <atomic>