
Hess, Frank wrote:
Splitting promise from future seems like a good idea, it should make the future class in libpoet a little less confusing. One thing your code reminded me of is forwarding exceptions to the future, something I put off then completely forgot about in libpoet. Since I'm trying to provide an active function object that wraps an ordinary passive function, for the general case I would need to call something like your promise::fail() from a catch block that catches exceptions thrown by the passive function. Unfortunately, that would require something like a templated catch. It seems the best I can do is provide special handling for some particular type of exception, like a boost::shared_ptr<std::exception> and if the passive function throws anything else, it just gets forwarded to the future as something like a poet::unknown_exception.
This won't be a problem in the next C++ if N2179 passes: http://www.pdimov.com/cpp/N2179.html My implementation provides a partial emulation of N2179: http://www.pdimov.com/cpp/N2179/exception_ptr.hpp http://www.pdimov.com/cpp/N2179/exception_ptr.cpp