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

Function checkAndlogLarge

sample/checkAndlogLarge.cpp:4–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include <iostream>
3
4constexpr bool checkAndlogLarge(double value)
5{
6 using namespace matchit;
7
8 auto const square = [](auto &&v)
9 { return v * v; };
10 Id<double> s;
11 return match(value)(
12 pattern | app(square, and_(_ > 1000, s)) =
13 [&]
14 {
15 std::cout << value << "^2 = " << *s << " > 1000!" << std::endl;
16 return true;
17 },
18 pattern | _ = expr(false));
19}
20
21// comment out std::cout then uncomment this.
22// static_assert(checkAndlogLarge(100));

Callers 1

mainFunction · 0.85

Calls 4

appFunction · 0.85
matchFunction · 0.50
and_Function · 0.50
exprFunction · 0.50

Tested by

no test coverage detected