Corrected invocation of boost::promise<T>::set_exception
Closes #534
Sorry, but I don't think this is a good solution. boost::promise's destructor is not virtual, so deriving from it might cause some problem.
Maybe we should replace all Promise::set_exception with a set_exception(Promise &pro, exception_ptr err) function. With boost enabled, we can make a specialized set_exception to handle these stuffs.
// For std::promise
void set_exception(Promise &pro, exception_ptr err) {
pro.set_exception(err);
}
// For boost::promise
void set_exception(Promise &pro, exception_ptr err) {
try {
rethrow_exception(err);
} catch (...) {
pro.set_exception(boost::current_exception());
}
}
I'll do some tests on this solution later.
The only potential problem with non-virtual destructor is destruction through a pointer to a base class. Since pointers to the base (boost::promise<T>) are not used in the code directly, this cannot happen.
To detect the problem at compile time, CppCoreGuidlines recommend to make the constructor of the base protected. Obviously, we cannot follow this recommendation here. However, such check is not mandatory and is actually not needed in this case.