| 4 | using namespace matchit; |
| 5 | |
| 6 | void sample1() |
| 7 | { |
| 8 | auto const num = std::make_optional(4); |
| 9 | |
| 10 | Id<int32_t> x; |
| 11 | match(num)( |
| 12 | pattern | some(x.at(_ < 5)) = |
| 13 | [&] |
| 14 | { std::cout << "less than five: " << *x << std::endl; }, |
| 15 | pattern | some(x) = [&] |
| 16 | { std::cout << *x << std::endl; }, |
| 17 | pattern | none = [&] {}); |
| 18 | } |
| 19 | |
| 20 | template <typename T> |
| 21 | std::ostream &operator<<(std::ostream &o, std::optional<T> const &op) |