In relation with This question.
C++11 adds the ability to marshall an exception to a different threads (using std::exception_ptr
) and resumes its propagation.
I was wondering if such a propagation was automatic, that is: if I fail to handle an exception in a thread, is it automatically propagated in the parent thread ?
I somewhat doubt it (or it would have to wait explicitly for the join
in some way), but I am not savvy on C++11 yet. Notably, I think that in the case of a std::future
, it could store the exception automatically.
Propagation is not automatic with thread
. If a thread throws, and that exception is not caught, the program terminates no matter what.
future
and shared_future
will store an uncaught exception in the child thread. That exception is then automatically propagated when get
is called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With