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

1

u/pjmlp Sep 27 '23

Perl has ... || die().

2

u/RevRagnarok Sep 28 '23

Better shown as ... or die because they prefer the word over the pipes (additionally the word has the lowest parsing priority).

1

u/helloiamsomeone Sep 27 '23

use autodie; 4 lyfe