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

Function sample1

sample/Extra-Conditionals-with-Match-Guards.cpp:6–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4using namespace matchit;
5
6void 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
20template <typename T>
21std::ostream &operator<<(std::ostream &o, std::optional<T> const &op)

Callers 1

mainFunction · 0.70

Calls 2

matchFunction · 0.50
atMethod · 0.45

Tested by

no test coverage detected