C++ Logo

std-proposals

Advanced search

Re: [std-proposals] escaping nested scopes : __escape

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Tue, 2 May 2023 23:28:17 +0100
On Mon, May 1, 2023 at 3:10 PM Sebastian Wittmeier via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> You can use a lambda at the appropriate position instead.
>
>
>
> [&] {
>
> for (int i = 0; i < x: i++) {
>
> for (int j = 0; j < y; j++) {
>
> for (int k = 0; k < z; k++) {
>
> if (something)
>
> return;
>
> }
>
> }
>
> }
>
> }();


Fair enough that covers _one_ of the use cases, but there are many
more use cases.

Actually just today I tried to use your lambda strategy in my own code
but I couldn't. I had a nested loop like this:

for ( ................. )
{
    for (................ )
    {
        for (...............)
        {
            co_yield some_value;
        }
    }
}

I couldn't wrap this up in a lambda because you can't have 'co_yield'
inside a lambda.

Received on 2023-05-02 22:28:29