Documentation Home >> Headers >> <thread> Header >> std::thread >> std::thread::swap member function

Exchanges ownership of their associated threads of execution between two std::thread objects.

void swap(thread& other);

Effects:

If other has an associated thread of execution prior to the call, that thread of execution is now associated with *this. Otherwise *this has no associated thread of execution. If *this has an associated thread of execution prior to the call, that thread of execution is now associated with other. Otherwise other has no associated thread of execution.

Postconditions:

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

Throws:

Nothing

Header

#include <thread>

See Also