Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-08-17 13:07:09


From: "Eric Woodruff" <Eric.Woodruff_at_[hidden]>
> Peter,
>
> I can't accept the idea that the user always has to modify the throw
points
> (even though boost::throw_exception will be available and can easily do
all
> of the wrapping). Sometimes that isn't possible (for things like third
party
> frameworks). Grantid, that the user already has to construct something
> compatible with boost::function0 to give to their thread.
>
> We can provide a function0 wrapper that will wrap a listed set of
exceptions
> for them.

Yes, a function object wrapper that translates a given set of exceptions can
do the trick. The good thing about this approach is that it's modular, has
no dependency on thread<>, and can be useful on its own.

template<class R, class F, class T, class L> struct exception_translator
{
    R operator()();
    // try { f() }
    // for each E in sort(L): catch(E const & e) { throw T(e); }
};


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