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

Function quoRem

sample/quotientRemainder.cpp:13–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11};
12
13constexpr std::array<int32_t, 2> quoRem(int32_t dividend, int32_t divisor)
14{
15 using namespace matchit;
16 Id<int32_t> q;
17 Id<int32_t> r;
18 return match(dividend)(
19 // clang-format off
20 pattern | qr(divisor)(q, r) = [&] { return std::array<int32_t, 2>{*q, *r}; },
21 pattern | _ = [&] { return std::array<int32_t, 2>{0, 0}; }
22 // clang-format on
23 );
24}
25
26constexpr auto qrResult1 = quoRem(12, 6);
27static_assert(qrResult1[0] == 2);

Callers 2

mainFunction · 0.85

Calls 1

matchFunction · 0.50

Tested by

no test coverage detected