30 Atomic operations library [atomics]

30.8 Non-member functions [atomics.nonmembers]

A non-member function template whose name matches the pattern atomic_­f or the pattern atomic_­f_­explicit invokes the member function f, with the value of the first parameter as the object expression and the values of the remaining parameters (if any) as the arguments of the member function call, in order.
An argument for a parameter of type atomic<T>::value_­type* is dereferenced when passed to the member function call.
If no such member function exists, the program is ill-formed.
template<class T> void atomic_init(volatile atomic<T>* object, typename atomic<T>::value_type desired) noexcept; template<class T> void atomic_init(atomic<T>* object, typename atomic<T>::value_type desired) noexcept;
Effects: Non-atomically initializes *object with value desired.
This function shall only be applied to objects that have been default constructed, and then only once.
[Note
:
These semantics ensure compatibility with C.
end note
]
[Note
:
Concurrent access from another thread, even via an atomic operation, constitutes a data race.
end note
]
[Note
:
The non-member functions enable programmers to write code that can be compiled as either C or C++, for example in a shared header file.
end note
]