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

Function sample2

sample/Slice-pattern.cpp:15–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13}
14
15void sample2()
16{
17 // Dynamic size
18 auto const v = std::vector<int32_t>{1, 2, 3};
19 Id<int32_t> a, b, c;
20 match(v)(
21 // format off
22 pattern | ds(a, b) =
23 [] { /* this arm will not apply because the length doesn't match */ },
24 pattern | ds(a, b, c) = [] { /* this arm will apply */ },
25 pattern | ds(_) =
26 [] { /* this wildcard is required, since the length is not known
27 statically */
28 } // format on
29 );
30}
31
32int32_t main()
33{

Callers 1

mainFunction · 0.70

Calls 2

matchFunction · 0.50
dsFunction · 0.50

Tested by

no test coverage detected