Boost logo

Boost :

Subject: Re: [boost] [inspect] exceptions (FW: [Boost-users] no exceptions)
From: Vicente BOTET (vicente.botet_at_[hidden])
Date: 2011-03-22 15:27:21


> Message du 22/03/11 20:18
> De : "Krzysztof Czainski" <1czajnik_at_[hidden]>
> A : boost_at_[hidden]
> Copie à :
> Objet : Re: [boost] [inspect] exceptions (FW: [Boost-users] no exceptions)
>
> 2011/3/22 Emil Dotchevski
>
> > Why use BOOST_THROW_EXCEPTION to throw?
> >
> > - Typically, there is no need to do anything else to support
> > BOOST_NO_EXCEPTIONS builds;
> >
> > - Enables boost::exception_ptr, so the exceptions you throw can be
> > transported between threads;
> >
> > - Enables boost::error_info, so users can attach stuff to exceptions.
> >
> > - Enables better messages from boost::diagnostic_information.
> >
>
> +1
>
> What about boost/detail/no_exceptions_support.hpp? Could that file be moved
> to boost/exception for public use? I use it, but don't feel comfortable with
> it being in the detail directory.

+1 As BOOST_THROW_EXCEPTION is not enough to support BOOST_NO_EXCEPTIONS builds.

These macros clearly help to achieve this goal.

Best,
Vicente

Example of use from the file:

void foo() {
BOOST_TRY {
...
} BOOST_CATCH(const std::bad_alloc&) {
...
BOOST_RETHROW
} BOOST_CATCH(const std::exception& e) {
...
}
BOOST_CATCH_END
}

With exception support enabled it will expand into:

void foo() {
{ try {
...
} catch (const std::bad_alloc&) {
...
throw;
} catch (const std::exception& e) {
...
}
}
}

With exception support disabled it will expand into:

void foo() {
{ if(true) {
...
} else if (false) {
...
} else if (false) {
...
}
}
}


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