Boost logo

Boost :

Subject: Re: [boost] Interest in breakable labeled scope emulation?
From: TONGARI (tongari95_at_[hidden])
Date: 2013-01-14 22:04:04


2013/1/14 Vicente J. Botet Escriba <vicente.botet_at_[hidden]>

> Yeah. I was your macro forbid the access from outside the block. I though
> that the trick was used only to be able to add a label at the end of the
> block. But the use of the variable on the BREAK macro make it fail. Really
> clever.
>
> #define BOOST_SCOPE(name) \
> if (const bool LABELED_SCOPE_##name = false){BOOST_BREAK(name);
> name##_end_scope:;} else
>
> #define BOOST_BREAK(name) \
> (void)LABELED_SCOPE_##name; goto name##_end_scope
>

Modification:

#define BOOST_BREAK(name) \
do {goto name##_end_scope;} while (LABELED_SCOPE_##name)

This makes it a single stmt and the below should work:

if (...)
     BOOST_BREAK(...);


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