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

Function symmetricArray

sample/symmetric.cpp:19–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19constexpr bool symmetricArray(std::array<int32_t, 5> const &arr)
20{
21 using namespace matchit;
22 Id<int32_t> i, j;
23 return match(arr)(
24 // clang-format off
25 pattern | ds(i, j, _, j, i) = expr(true),
26 pattern | _ = expr(false)
27 // clang-format on
28 );
29}
30
31static_assert(symmetricArray(std::array<int32_t, 5>{5, 0, 3, 7, 10}) == false);
32static_assert(symmetricArray(std::array<int32_t, 5>{5, 0, 3, 0, 5}) == true);

Callers 1

symmetric.cppFile · 0.85

Calls 3

matchFunction · 0.50
dsFunction · 0.50
exprFunction · 0.50

Tested by

no test coverage detected