Documentation Home >> Headers >> <thread> Header >> std::thread >> std::thread Move-Constructor

Transfers ownership of a thread of execution from one std::thread object to a newly-created std::thread object.

thread(thread&& other);

Effects:

Constructs a std::thread instance. If other has an associated thread of execution prior to the constructor invocation, that thread of execution is now associated with the newly-created std::thread object. Otherwise the newly-created std::thread object has no associated thread of execution.

Postconditions:

For a newly-constructed std::thread object x, x.get_id() is equal to the value of other.get_id() prior to the constructor invocation. other.get_id()==id().

Throws:

Nothing

Note:

std::thread objects are not CopyConstructible, so there is no copy-constructor, only this move constructor

Header

#include <thread>

See Also