r/cpp • u/javascript • 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
View all comments
Show parent comment
1
u/aruisdante May 09 '26
Yeah, my previous employer had a
TRYmacro implemented with statement exprs that let you use optional/result (they were on 17 so had to roll their own expected) in a more procedurally oriented way if the only action for “sub operation failed” was to forward along the nullopt/error channel. Introducing it dramatically improved adoption ofresult: the monadics are confusing to a lot of people, and especially cumbersome to use if you have a coding standard that requires explicit capture of all variables in lambdas making them excessively verbose. Letting them do things the way they were used to made the change less scary/difficult.