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

Function eval

sample/eval.cpp:5–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3
4template <typename T1, typename T2>
5constexpr auto eval(std::tuple<char, T1, T2> const &expr)
6{
7 using namespace matchit;
8 Id<T1> i;
9 Id<T2> j;
10 return match(expr)(
11 pattern | ds('+', i, j) = i + j, pattern | ds('-', i, j) = i - j,
12 pattern | ds('*', i, j) = i * j, pattern | ds('/', i, j) = i / j,
13 pattern | _ = []
14 {
15 assert(false);
16 return -1;
17 });
18}
19
20#if __cplusplus > 201703L
21constexpr auto result = eval(std::make_tuple('*', 5, 6));

Callers 2

eval.cppFile · 0.70
mainFunction · 0.70

Calls 2

matchFunction · 0.50
dsFunction · 0.50

Tested by

no test coverage detected