MCPcopy Create free account
hub / github.com/BowenFu/matchit.cpp / print_leftmost

Function print_leftmost

sample/Dereference-Pattern.cpp:16–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16void 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
35int32_t main()
36{

Callers 1

mainFunction · 0.85

Calls 3

appFunction · 0.85
matchFunction · 0.50
and_Function · 0.50

Tested by

no test coverage detected