An std::packaged_task
has an associated std::future
object that will contain the exception (or the result of the task). You can get this future by calling the get_future()
function from std::packaged_task
.
This means that for throw
is an exception inside the function associated with the packed task, so that the exception can be caught by the future task (and re-selected when get()
is called on the future object).
For instance:
#include <thread>
source share