| 3 | #include <iostream> |
| 4 | |
| 5 | constexpr 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 | |
| 17 | static_assert(sumIs(std::array<int32_t, 2>{5, 6}, 11)); |
| 18 |