Spreading an exception by thread?

Regarding This Question .

C ++ 11 adds the ability to route exceptions to other threads (using std::exception_ptr ) and resumes its distribution.

I was wondering if this distribution was automatic, that is: if I cannot handle the exception in the thread, does it automatically propagate in the parent thread?

I have some doubts about this (or he will have to wait explicitly for join in some way), but I still do not understand C ++ 11. It is noteworthy that I think that in the case of std::future it can automatically save this exception.

+7
source share
1 answer

Distribution is not automatic with thread . If the thread is thrown and this exception is not caught, the program terminates no matter what.

future and shared_future will store the uncaught exception in the child thread. Then this exception is automatically thrown when get is called.

+8
source

All Articles