Boost logo

Boost :

Subject: Re: [boost] Boost and exceptions
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-06-23 16:13:49


on Sat Jun 23 2012, "Robert Ramey" <ramey-AT-rrsd.com> wrote:

> If you really like boost::exception your code when you eventually can
> eventually rethrow
>
> catch (std::exception e){
> BOOST_EXCEPTION_THROW_EXCEPTION(e)
> }

IIUC, even if you change it to catch by reference, as you should, and
even if std::exception weren't an abstract base class, which it is, that
approach will slice the caught exception and lose all the information
thrown with it. BOOST_EXCEPTION_THROW_EXCEPTION needs to copy the
exception object into this type it builds with multiple inheritance from
boost::exception, and it needs to do this with full knowledge of the
static type of the exception being thrown.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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