public member function


void set_exception_at_thread_exit (exception_ptr p);
Set exception at thread exit
Stores the exception pointer p in the shared state without making it ready immediately. Instead, it will be made ready automatically at thread exit, once all objects of thread storage duration have been destroyed.

If a future object that is associated to the same shared state is waiting on a call to future::get, it stays blocked until the thread ends. Once the thread ends, it throws the exception object pointed by p.

Notice that calling this function already sets a value in the shared state, and any call that modifies this value between this call and the end of the thread will throw future_error with promise_already_satisfied as error condition.


An exception_ptr object.
exception_ptr is a smart pointer type designed to reference exception objects.

Return value


Data races

The promise object is modified.
The shared state is modified as an atomic operation (causing no data races).

Exception safety

Basic guarantee: if an exception is thrown, the promise object is in a valid state.

This member function throws an exception on the following conditions:
exception typeerror conditiondescription
future_errorfuture_errc::no_stateThe object has no shared state (it was moved-from)
future_errorfuture_errc::promise_already_satisfiedThe shared state already has a stored value or exception
Depending on the library implementation, this member function may also throw exceptions to report other situations.

See also