template< class T >
bool atomic_is_lock_free( const std::shared_ptr<T>* p );
If multiple threads of execution access the same std::shared_ptr 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::atomic_load, std::atomic_store, etc.)
Note that the control block of a shared_ptr is thread-safe: different std::shared_ptr 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.
p. As with the non-specialized std::atomic_load_explicit,
mocannot be std::memory_order_release or std::memory_order_acq_rel
rin the shared pointer pointed-to by
patomically, effectively executing p->swap(r). As with the non-specialized std::atomic_store_explicit,
mocannot be std::memory_order_acquire or std::memory_order_acq_rel.
rin the shared pointer pointed to by
pand returns the value formerly pointed-to by
p, atomically. Effectively executes p->swap(r) and returns a copy of
rafter the swap.
expected. If they are equivalent (store the same pointer value, and either share ownership of the same object or are both empty), assigns
*pusing the memory ordering constraints specified by
successand returns true. If they are not equivalent, assigns
*expectedusing the memory ordering constraints specified by
failureand returns false.
All these functions invoke undefined behavior if
p is a null pointer.
|p, expected||-||a pointer to a std::shared_ptr|
|r, desired||-||a std::shared_ptr|
|mo, success, failure||-||memory ordering selectors of type std::memory_order|
These functions do not throw exceptions.
 Return value
These functions are typically implemented using mutexes, stored in a global hash table where the pointer value is used as the key.
The Concurrency TS offers atomic smart pointer classes
atomic_weak_ptr as a replacement for the use of these functions.
|This section is incomplete|
Reason: no example
 Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
|DR||Applied to||Behavior as published||Correct behavior|
|LWG 2980||C++11|| empty
||equivalent if they store the same pointer value|
 See also
| checks if the atomic type's operations are lock-free |
| atomically replaces the value of the atomic object with a non-atomic argument |
| atomically obtains the value stored in an atomic object |
| atomically replaces the value of the atomic object with non-atomic argument and returns the old value of the atomic |
| atomically compares the value of the atomic object with non-atomic argument and performs atomic exchange if equal or atomic load if not |