Exception propagation and std::future

前端 未结 2 1165
滥情空心
滥情空心 2021-02-19 09:39

My understanding is that when an asynchronous operation throws an exception, it will be propagated back to a thread that calls std::future::get(). However, when su

2条回答
  •  天涯浪人
    2021-02-19 10:32

    It is ignored and discarded, just like if you wait() for a value but never get() it.

    wait() simply says "block until the future is ready", be that ready with a value or exception. It's up to the caller to actually get() the value (or exception). Usually you'll just use get(), which waits anyway.

提交回复
热议问题