Documentation Home >> Headers >> <mutex> Header >> std::unique_lock >> std::unique_lock::swap member function

Exchanges ownership of their associated unique_locks of execution between two std::unique_lock objects.

void swap(unique_lock&& other);

Effects:

If other owns a lock on a mutex prior to the call, that lock is now owned by *this. If *this owns a lock on a mutex prior to the call, that lock is now owned by other.

Postconditions:

this->mutex() is equal to the value of other.mutex() prior to the call. other.mutex() is equal to the value of this->mutex() prior to the call. this->owns_lock() is equal to the value of other.owns_lock() prior to the call. other.owns_lock() is equal to the value of this->owns_lock() prior to the call.

Throws:

Nothing

Header

#include <mutex>

See Also