[thread.thread.constr] (original) (raw)

32 Thread support library [thread]

32.4 Threads [thread.threads]

32.4.2 Class thread [thread.thread.class]

32.4.2.2 Constructors [thread.thread.constr]

Effects:The object does not represent a thread of execution.

Postconditions: get_­id() == id().

template<class F, class... Args> explicit thread(F&& f, Args&&... args);

Constraints: remove_­cvref_­t<F> is not the same type as thread.

Mandates:The following are all true:

Preconditions: decay_­t<F> and each type in decay_­t<Args> meet theCpp17MoveConstructible requirements.

Effects:The new thread of execution executes

invoke(decay-copy(std::forward(f)), decay-copy(std::forward(args))...)

with the calls todecay-copy being evaluated in the constructing thread.

Any return value from this invocation is ignored.

[ Note

:

This implies that any exceptions not thrown from the invocation of the copy of f will be thrown in the constructing thread, not the new thread.

end note

]

If the invocation of invoke terminates with an uncaught exception,terminate is called.

Synchronization:The completion of the invocation of the constructor synchronizes with the beginning of the invocation of the copy of f.

Postconditions: get_­id() != id().

*this represents the newly started thread.

Throws: system_­error if unable to start the new thread.

Error conditions:

thread(thread&& x) noexcept;

Postconditions: x.get_­id() == id() and get_­id() returns the value of x.get_­id() prior to the start of construction.