[Exceptions] Boost exception relationship with std exception & streams
I'm about to use boost.exception in a library which may require to be built in environnement where using std is eitehr impossible or has huge penalty one may want to avoid. My main idea was to use the BOOST_THROW_EXCEPTION and the error_info to build the diagnostic infos into exception class then: - if BOOST_NO_EXCEPTIONS is not set, process normally - if BOOST_NO_EXCEPTIONS is set, then jump into a throw_exception function that just stream diagnsotic_info to cerr or some such - if BOOST_NO_EXCEPTIONS and NT2_NO_STREAM is set, jump to a throw_exception that fprintf the diagnostic_info to stderr My question is: how deeply std elements ar eintegrated in boost::exception and is this kind of scheme workable with current version ?
On Sun, Jun 20, 2010 at 3:07 AM, joel falcou
I'm about to use boost.exception in a library which may require to be built in environnement where using std is eitehr impossible or has huge penalty one may want to avoid.
My main idea was to use the BOOST_THROW_EXCEPTION and the error_info to build the diagnostic infos into exception class then: - if BOOST_NO_EXCEPTIONS is not set, process normally - if BOOST_NO_EXCEPTIONS is set, then jump into a throw_exception function that just stream diagnsotic_info to cerr or some such - if BOOST_NO_EXCEPTIONS and NT2_NO_STREAM is set, jump to a throw_exception that fprintf the diagnostic_info to stderr
Boost Exception does support the error info functionality even in BOOST_NO_EXCEPTIONS builds. For example, the user-defined boost::throw_exception function can use boost::diagnostic_information.
My question is: how deeply std elements ar eintegrated in boost::exception
Pretty deeply. A quick search reveals the following std:: elements used by boost::exception: std::string std::map std::pair std::exception and the other std exception types std::ostringstream So I don't think it'd be easy at all to de-STL the Boost Exception library. Also note that BOOST_NO_EXCEPTIONS builds still require the exception types to derive from std::exception. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
Emil Dotchevski wrote:
Boost Exception does support the error info functionality even in BOOST_NO_EXCEPTIONS builds. For example, the user-defined boost::throw_exception function can use boost::diagnostic_information.
so I can grab the textual contents of diagnostic_info and do w/e with it.
So I don't think it'd be easy at all to de-STL the Boost Exception library. Also note that BOOST_NO_EXCEPTIONS builds still require the exception types to derive from std::exception.
I kinda feared that. Guess I'll for no-exceptions on machine where std is a no-go and remove the intermediate level. Thanks
On Sun, Jun 20, 2010 at 11:20 PM, Joel Falcou
Emil Dotchevski wrote:
Boost Exception does support the error info functionality even in BOOST_NO_EXCEPTIONS builds. For example, the user-defined boost::throw_exception function can use boost::diagnostic_information.
so I can grab the textual contents of diagnostic_info and do w/e with it.
Yes.
So I don't think it'd be easy at all to de-STL the Boost Exception library. Also note that BOOST_NO_EXCEPTIONS builds still require the exception types to derive from std::exception.
I kinda feared that. Guess I'll for no-exceptions on machine where std is a no-go and remove the intermediate level.
You can define BOOST_EXCEPTION_DISABLE, which disables the Boost Exception library itself, leaving the legacy boost::throw_exception behavior (which still has two flavors, depending on BOOST_NO_EXCEPTIONS). In this configuration no STL components are used except for std::exception. You can then #ifdef your code that uses the Boost Exception library with BOOST_EXCEPTION_DISABLE. HTH, Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
Emil Dotchevski wrote:
You can define BOOST_EXCEPTION_DISABLE, which disables the Boost Exception library itself, leaving the legacy boost::throw_exception behavior (which still has two flavors, depending on BOOST_NO_EXCEPTIONS). In this configuration no STL components are used except for std::exception. You can then #ifdef your code that uses the Boost Exception library with BOOST_EXCEPTION_DISABLE.
Ok, so I can say that if NT2_CONFIG_NO_STREAMS is set, I set BOOST_EXCEPTION_DISABLE and no stream header will be included basically ?.
On Tue, Jun 22, 2010 at 1:41 AM, joel falcou
Emil Dotchevski wrote:
You can define BOOST_EXCEPTION_DISABLE, which disables the Boost Exception library itself, leaving the legacy boost::throw_exception behavior (which still has two flavors, depending on BOOST_NO_EXCEPTIONS). In this configuration no STL components are used except for std::exception. You can then #ifdef your code that uses the Boost Exception library with BOOST_EXCEPTION_DISABLE.
Ok, so I can say that if NT2_CONFIG_NO_STREAMS is set, I set BOOST_EXCEPTION_DISABLE and no stream header will be included basically ?.
In terms of what headers are included by boost/throw_exception.hpp,
the only difference BOOST_EXCEPTION_DISABLE makes is that it prevents
boost/exception/exception.hpp and boost/current_function.hpp from
being included, however these headers don't include anything and are
*very* lightweight.
With or without BOOST_EXCEPTION_DISABLE boost/throw_exception.hpp includes:
#include
participants (3)
-
Emil Dotchevski
-
joel falcou
-
Joel Falcou