How to get the exception reported to boost::future?

Viewed 1871

If I use Boost futures, and the future reports true to has_exception(), is there any way to retrieve that exception? For example, here is the following code:

int do_something() {
    ...
    throw some_exception();
    ...  
}

...

boost::packaged_task task(do_something);
boost::unique_future<int> fi=task.get_future();
boost::thread thread(boost::move(task));
fi.wait();
if (fi.has_exception()) {
    boost::rethrow_exception(?????);
}
...

The question is, what should be put in the place of "?????"?

1 Answers
Related