cpp/memory/shared ptr/atomic

If multiple threads of execution access the same std object without synchronization and any of those accesses uses a non-const member function of shared_ptr then a data race will occur unless all such access is performed through these functions, which are overloads of the corresponding atomic access functions (std, std, etc.)

Note that the control block of a shared_ptr is thread-safe: different std objects can be accessed using mutable operations, such as operator= or reset, simultaneously by multiple threads, even when these instances are copies, and share the same control block internally.

@1@ Determines whether atomic access to the shared pointer pointed-to by is lock-free. @2@ Equivalent to @3@ Returns the shared pointer pointed-to by. As with the non-specialized std, cannot be std or std @4@ Equivalent to @5@ Stores the shared pointer in the shared pointer pointed-to by  atomically, effectively executing. As with the non-specialized std, cannot be std or std. @6@ Equivalent to @7@ Stores the shared pointer in the shared pointer pointed to by  and returns the value formerly pointed-to by, atomically. Effectively executes and returns a copy of  after the swap. @8@ Equivalent to @9@ Equivalent to @10@ Compares the shared pointers pointed-to by and. If they are equivalent (store the same pointer value, and either share ownership of the same object or are both empty), assigns into  using the memory ordering constraints specified by  and returns. If they are not equivalent, assigns into  using the memory ordering constraints specified by  and returns. @11@ Same as 10), but may fail spuriously.

All these functions invoke undefined behavior if is a null pointer.

Exceptions
These functions do not throw exceptions.

Return value
@1@ if atomic access is implemented using lock-free instructions @2,3@ A copy of the pointed-to shared pointer. @4,5@ (none) @6,7@ A copy of the formerly pointed-to shared pointer @8,9,10,11@ if the shared pointers were equivalent and the exchange was performed,  otherwise.