r/cpp • • May 09 '26

Any good tech talks leveraging statement expressions?

Lambdas do a great job in a lot of cases but sometimes you need a statement expression. Any good content on youtube?

14 Upvotes

33 comments sorted by

View all comments

Show parent comment

1

u/javascript May 09 '26

It's definitely in the same space but I don't see my main question answered: Can you normal return from a do block? Like return the whole function?

3

u/fdwr fdwr@github 🔍 May 09 '26

Can you normal return from a do block?

Yep. See 2.5 in the control flow examples.

int outer() {
    int g = do {
        if (cond) {
            do return 1;
        }

        return 3;
    };
}

3

u/javascript May 09 '26

Splendid! That would be very useful to have in C++