Boost logo

Boost :

Subject: Re: [boost] Boost and exceptions
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2012-06-23 15:58:38


On Sat, Jun 23, 2012 at 7:22 AM, John Maddock <boost.regex_at_[hidden]>wrote:

> From what I can find in the list archives [1], Boost.FileSystem also had a
>>>>
>>> similar issue with the requirement that thrown exceptions inherit from
>>> std::exception. However, I'm not sure if [1] prompted the
>>> FileSystem-local
>>> hook or if it was resolved in some other way.
>>>
>>
>> All exceptions should inherit from std::exception. There is no need to
>> involve the boost::exception type in your code to use throw_exception.
>>
>
> This works both ways - you can and should inherit from std::exception
> whether you use BOOST_THROW_EXCEPTION or not, it's just that in the latter
> case, they will also inherit from boost::exception (via multiple
> inheritance if I understand the machinery correctly).
>

Yes, any exception emitted by boost::throw_exception can be intercepted as
std::exception (you get a compile error if you pass a type that doesn't
derive from std::exception), or as boost::exception (it's inserted as a
base type if the passed type doesn't already derive from it).

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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