
Le 13/01/13 20:37, Brian Ravnsgaard Riis a écrit :
Den Sun, 13 Jan 2013 20:30:14 +0100 skrev Vicente J. Botet Escriba <vicente.botet@wanadoo.fr>:
[snip]
Of course in order to be really structured 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]
So, the underlying idea is to get something like "break" and "continue" to work inside any "named" block, not just loops? If so (as you demonstrate above) I'm fairly certain a correct solution cannot be implemented using just the preprocessor. I believe preprocesor can provide a solution that allows you write correct programs but don't avoid bad uses. Even in this case, exiting from nested loops could be more easy to write/read as showed here.
BOOST_NAMED_BLOCK(L) for(;;) { while (cnd) { if (cnd2) BOOST_BREAK(L); // go to [1] } } // [1] Well this is always subjective ;-) Best, Vicente