|
Boost : |
From: Guillaume Melquiond (guillaume.melquiond_at_[hidden])
Date: 2004-03-01 05:11:44
Le lun 01/03/2004 à 10:26, Pavel Vozenilek a écrit :
> "Daryle Walker" <darylew_at_[hidden]> wrote
>
> > You might want to use:
> >
> > #define BOOST_INDEXED_SET_CATCH(x) if(true) ; else
> >
> > instead. This way, any dangling "else" in the outside code doesn't get
> > attached to your macro by mistake.
> >
> You found real problem in current macros! For example:
>
> if (...)
> BOOST_TRY {
> ...
> } BOOST_CATCH(...) {
> ...
> }
> else {
> ...
> }
>
> would behave differently depending on
> BOOST_NO_EXCEPTIONS.
>
>
> Here are macros resistant to this problem:
>
> #if !(defined BOOST_NO_EXCEPTIONS)
> # define BOOST_TRY try
> # define BOOST_CATCH(x) catch(x)
> # define BOOST_RETHROW throw
> #else
> # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
> # define BOOST_TRY if ("")
> # else
> # define BOOST_TRY if (1)
> # endif
> # define BOOST_CATCH(x) else
> # define BOOST_RETHROW
> #endif
>
>
> /Pavel
With this new definition of the macros, it seems to me you can't use
multiple catch (a handler sequence). But I don't see any way to define
the macros such that BOOST_TRY {} BOOST_CATCH(_) {} BOOST_CATCH(_) {}
works as expected. Adding a BOOST_TRY_END would solve the problem. But
maybe someone can find a better solution without adding any macro.
Regards,
Guillaume
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk