views:

911

answers:

3
+4  Q: 

boost exceptions

Do all boost exceptions derive from std::exception? If not do they all derive from some base exception class?

+1  A: 

I believe so. Can't think of a boost library throwing something non-std::exception based.

Assaf Lavie
+3  A: 

according to this( http://www.boost.org/doc/libs/1_37_0/libs/exception/doc/exception_exception_hpp.html) however it seems not

this link on the boost web site further explains how to correctly use std::exception and boost::exception

digitalSurgeon
Boost.Exception is a framework for storable and re-throwable exceptions. They're not thrown directly from any boost library. The FAQ http://www.boost.org/doc/libs/1_39_0/libs/exception/doc/frequently_asked_questions.html explains why `boost::exception` doesn't inherit from `std::exception`.
+1  A: 

A "good Boost citizen" library should throw using boost::throw_exception, in order to support configurations where exception handling is disabled.

The boost::throw_exception function requires that the type of the passed exception derives publicly from std::exception (as of version 1.37.0 or thereabouts boost::throw_exception will issue a compile error if that requirement is not met.) In addition and by default, exceptions emitted using boost::throw_exception derive from boost::exception.

However, there is no requirement for Boost libraries to throw exceptions through boost:throw_exception or to derive from std::exception.

Emil