|
Boost : |
From: Josh Napoli (jnapoli_at_[hidden])
Date: 2007-11-08 18:45:53
> Emil Dotchevski wrote:
> > > > Here is a generic exception_ptr implementation based on a
registry
> > of
> > > > exception types. (http://joshuanapoli.com/exception/) The
registry
> > is
> > >
> > > If boost::throw_exception is modified such that its postcondition
is
> > > that the exception object it throws derives from boost::exception
(I
> > > can't think of a reason not to), cloning can be implemented
> > > intrusively without a need for registration.
> >
> > I would hope to save exceptions thrown from 3rd party libraries. An
> > intrusive approach wouldn't work.
>
> For boost::throw_exception to be able to register the exception type
> from 3rd party libraries, they must call boost::throw_exception.
No, they don't need to call throw_exception. Registration of an
exception type can occur separately from the throw. For example, a user
could register an exception thrown by a binary-only library. Then
current_exception() would be able to clone exceptions from the
unmodified library, even if it uses a "bare" throw statement.
register_exception<Lib::derived_error>();
try
{
//calls 'throw derived_error' and we can't change it to
throw_exception
Lib::raise_error();
}
catch(Lib::base_error&)
{
transfer_to_other_thread(current_exception()); //copies
derived_error
}
However, as you pointed out, any types registered by a DLL would need to
be manually unregistered before the DLL is unloaded. This seems
unacceptable. Does boost::serialization have this problem?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk