Boost logo

Boost :

Subject: Re: [boost] Boost and exceptions
From: Robert Ramey (ramey_at_[hidden])
Date: 2012-06-23 18:24:22


Kim Barrett wrote:
>
> boost::throw_exception (in the interesting case, where
> BOOST_NO_EXCEPTIONS and BOOST_EXCEPTION_DISABLE are both undefined)
> ensures that the thrown object is derived from boost::exception even
> if the argument is not. It does this (via enable_error_info(), which
> does the heavy lifting) by examining the type E of the argument. If E
> is derived from boost::exception, then just use the argument as is.
> Otherwise, construct a new object. The class of the new object
> derives from both E and boost::exception (multiple inheritance), and
> has a conversion constructor for arguments of type E which passes the
> argument to the new class's base E object's copy constructor. Apply
> that constructor to the original argument, and use the resulting
> object. (Note that throw requires the argument to be copy
> constructible, so the described mechanism imposes no new constraint on
> E by requiring copy construction.)

So any boost library which previously
used boost::throw exception with an exception which was non-copyable
would break? I guess we're lucky no one did that.

thanks for explaining this. I would never have figured it without
spending a lot of time.

Robert Ramey


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