Boost logo

Boost :

Subject: Re: [boost] Futures - Reviews Needed (January 5, 2009)
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-12-31 14:53:42


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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk