31 Dec 20:53
Re: Futures - Reviews Needed (January 5, 2009)
Steven Watanabe <watanabesj <at> gmail.com>
2008-12-31 19:53:42 GMT
2008-12-31 19:53:42 GMT
AMDG Steve Karmesin wrote: > A second issue has to do with capturing and rethrowing exceptions. This is a > very cool capability but the implementation is limited because it can't detect > and use user derived subtypes of the system exception types. This can be done > with external polymorphism and would be a significant improvement. > > Instead of storing a runtime_error store a pointer to an internal abstract base > class such as untyped_exception_wrapper. Derive from that a templated class > exception_wrapper that stores the user's type and can rethrow that type. > > Then the set_exception member can be template and the exception type, wraps it > with exception_wrapper and stores the pointer to the abstract base. > > Then when the user goes to get the value from the future and it finds that there > was an exception, it calls the rethrow method on the abstract base, the > templated derived class does the concrete rethrow of the user's type and the > user can then catch that type. This way the future library can catch and > rethrow exceptions of types that it knows nothing about. > > Below is some demonstration code for this pattern. > This functionality is already in Boost. http://www.boost.org/libs/exception/doc/tutorial_exception_ptr.html In Christ, Steven Watanabe _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
RSS Feed