Documentation Home >> Headers >> <jss/experimental_atomic.hpp> Header >> std::experimental::atomic_shared_ptr >> std::experimental::atomic_shared_ptr::exchange member function

Atomically store a new value and read the old one.

shared_ptr<T> exchange(
    shared_ptr<T> new_value,
    memory_order order = memory_order_seq_cst)
    noexcept;

Effects:

Atomically store new_value in *this and retrieve the existing value of *this.

Returns:

The value of *this immediately prior to the store.

Throws:

Nothing.

Note:

This is an atomic read-modify-write operation for the memory location comprising *this.

Header

#include <experimental/atomic>

See Also