| 14 | } |
| 15 | |
| 16 | void print_leftmost(const Node &node) |
| 17 | { |
| 18 | auto deref = [](auto &&e) -> decltype(auto) |
| 19 | { return *e; }; |
| 20 | using namespace matchit; |
| 21 | Id<int> v; |
| 22 | Id<Node> l; |
| 23 | |
| 24 | using N = Node; |
| 25 | match(node)( |
| 26 | pattern | and_(app(&N::value, v), |
| 27 | app(&N::lhs, nullptr)) = [&] |
| 28 | { std::cout << *v << '\n'; }, |
| 29 | pattern | app(&N::lhs, app(deref, l)) = [&] |
| 30 | { print_leftmost(*l); } |
| 31 | // ˆˆˆˆˆˆˆˆˆˆˆˆˆ dereference pattern |
| 32 | ); |
| 33 | } |
| 34 | |
| 35 | int32_t main() |
| 36 | { |