Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- optional<int> func1() {
- if (int num = rand() < 42) {
- return num;
- }
- return {};
- }
- optional<int> func2() {
- optional<int> val = func1();
- if (!val) {
- return {};
- }
- int num = val.value();
- ...
- }
- int val = optional_check(func2());
Add Comment
Please, Sign In to add comment