id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 8955,Request for more efficient way to get exception_ptr from future,Niall Douglas,viboes,"Vicente, Here is that Boost.Thread feature request for AFIO I mentioned a while ago. Here is the code example: {{{ shared_future> *thisresult=state.first->outsharedstates[idx].get(); // This seems excessive but I don't see any other legal way to extract the exception ... bool success=false; try { // Always must wait on the others, because some may be between decrementing the // atomic and returning their result to here. Any waiting is likely short. thisresult->get(); success=true; } catch(...) { exception_ptr e(afio::make_exception_ptr(afio::current_exception())); assert(e); complete_async_op(s.out[idx].first, s.out[idx].second, e); } if(success) complete_async_op(s.out[idx].first, s.out[idx].second); }}} Taken from https://github.com/BoostGSoC/boost.afio/blob/master/libs/afio/src/afio.cpp#L1027 Basically, we need to scan a sequence of futures for any exception states which right now means trying to get() from each and try...catch to grab any exception_ptr's. As this is inefficient, is there any chance of adding a new member function to future and shared_future: get_exception()? This is identical to get(), except it returns any exception state instead of throwing it. If there is no exception state, it returns a null exception_ptr. In other words, a very simple new feature, but one which lets us eliminate a lot of needless try...catch stanzas. My thanks in advance Vicente. Niall",Feature Requests,closed,Boost 1.55.0,thread,Boost 1.54.0,Optimization,fixed,,