Boost logo

Boost :

Subject: Re: [boost] Interest in breakable labeled scope emulation?
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-01-13 14:30:14


Le 13/01/13 17:13, Klaim - Joël Lamotte a écrit :
> break is a standard c++ keyword already.
Yes, BOOST_BREAK should be used instead
>
> Also I don't understand what problem this solve.
>
>
Exiting from nested loops is something that could be quite complex using
structured programming.

Named blocks try to make more structured a goto based solution, by
allowing only to restart/leave a block from inside it.

BOOST_NAMED_BLOCK(L)
for(;;)
{
   while (cnd)
   {

     if (cnd2) BOOST_BREAK(L); // go to [1]
   }
}
// [1]

Of course in order to be really structired the jumping to the underlying
label should be forbiden (by the compiler), but I don't think that a
preprocessor solution could take care of this. So the following not
desired and not structured code could compile even if we would like an
compile error.

BOOST_NAMED_BLOCK(L)
{
// ...
}
// [1]
//...
BOOST_BREAK(L); // go to [1]

HTH,
Vicente


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