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

Function sumIs

sample/sumIs.cpp:5–15  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include <iostream>
4
5constexpr bool sumIs(std::array<int32_t, 2> const &arr, int32_t s)
6{
7 using namespace matchit;
8 Id<int32_t> i, j;
9 return match(arr)(
10 // clang-format off
11 pattern | ds(i, j) | when(i + j == s) = expr(true),
12 pattern | _ = expr(false)
13 // clang-format on
14 );
15}
16
17static_assert(sumIs(std::array<int32_t, 2>{5, 6}, 11));
18

Callers 2

sumIs.cppFile · 0.85
mainFunction · 0.85

Calls 4

whenFunction · 0.85
matchFunction · 0.50
dsFunction · 0.50
exprFunction · 0.50

Tested by

no test coverage detected