Boost logo

Boost :

Subject: [boost] Interest in breakable labeled scope emulation?
From: TONGARI (tongari95_at_[hidden])
Date: 2013-01-13 07:30:52

Hi all,

One of the few things I appreciate in Java is the labeled-break feature.
I think C++ would provide it as well in future standard but it seems that
there's no even such a proposal.

In lack of the language feature, a simple emulation can be used:

#define BOOST_SCOPE(name) \
if (const bool LABELED_SCOPE_##name = false){break(name); name:;} else

#define break(name) \
(void)LABELED_SCOPE_##name; goto name;
Now we can write:

    cout << "123\n";

The real world usage would reside in nested loop&switch where labeled-break
really shines.

Thoughts? Sorry if this idea is too simple and somewhat rejected before...

Boost list run by bdawes at, gregod at, cpdaniel at, john at