Documentation Home >> Headers >> <thread> Header >> std::thread >> std::thread Move-Assignment Operator

Transfers ownership of a thread of execution from one std::thread object to another std::thread object.

thread& operator=(thread&& other);

Effects:

If this->joinable() would return true prior to the call, calls std::terminate() to abort the program. If other has an associated thread of execution prior to the assignment, that thread of execution is now associated with *this. Otherwise *this 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()==id().

Throws:

Nothing

Note:

std::thread objects are not CopyAssignable, so there is no copy-assignment operator, only this move-assignment operator.

Header

#include <thread>

See Also