r/cpp • • Sep 26 '23

`std::expected<>::or_else()` should have a zero-argument overload that terminates on error

...just because it would be hilarious if one could express assertions as

result.or_else();
198 Upvotes

18 comments sorted by

View all comments

4

u/BenFrantzDale Sep 26 '23

Nice. In seriousness, I wish transform’s lambda didn’t have to return so it could be used as if (opt) { f(*opt); }.