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?

13 Upvotes

33 comments sorted by

View all comments

Show parent comment

1

u/javascript May 09 '26

Great to hear from someone with expertise!

Is my implementation of the MY_TRY macro elsewhere in this thread sufficient for day to day use? Or are there footguns?

1

u/erichkeane Clang Maintainer(Templates), EWG Chair May 09 '26

I'd have to page in all the problems with them again, I haven't poked at them in a few years.

But my rule of thumb at one point was to never have a lifetime with side effects start in a statement expression, and definitely never do multiple returns when you do.