| 32 | } |
| 33 | |
| 34 | void sample2() |
| 35 | { |
| 36 | auto const x = std::make_optional(5); |
| 37 | auto const y = 10; |
| 38 | |
| 39 | Id<int32_t> n; |
| 40 | match(x)( |
| 41 | // clang-format off |
| 42 | pattern | some(50) = [&]{ std::cout << "Got 50" << std::endl; }, |
| 43 | // In `match(it)`, you can use variable inside patterns, just like literals. |
| 44 | pattern | some(y) = [&]{ std::cout << "Matched, n = " << *n << std::endl; }, |
| 45 | pattern | _ = [&]{ std::cout << "Default case, x = " << x << std::endl; } |
| 46 | // clang-format on |
| 47 | ); |
| 48 | |
| 49 | std::cout << "at the end: x = " << x << ", y = " << y << std::endl; |
| 50 | } |
| 51 | |
| 52 | void sample3() |
| 53 | { |