template (1)
template <class T> void atomic_init (volatile atomic<T>* obj, T val) noexcept;
template <class T> void atomic_init (atomic<T>* obj, T val) noexcept;
overloads (2)
void atomic_init (volatile A* obj, T val) noexcept;
void atomic_init (A* obj, T val) noexcept;
Initialize atomic object
Initializes obj with a contained value of val.

Calling this function on an atomic object that has already been initialized (either on construction or by calling this function earlier) causes undefined behavior (see atomic_store to modify the value of already-initialized atomics).


Pointer to an atomic object.
Type A represents other overloaded atomic types (in case the library does not implement the C-style atomic types as instantiations of atomic).
Value to initialize the contained object with.
T is the type of the value contained by the atomic object (atomic's template parameter).

Return value


Data races

This operation is not atomic: Accessing obj while being initialized may cause data races.

Exception safety

No-throw guarantee: never throws exceptions.

See also