| 2 | #include <iostream> |
| 3 | |
| 4 | constexpr int32_t factorial(int32_t n) |
| 5 | { |
| 6 | using namespace matchit; |
| 7 | assert(n >= 0); |
| 8 | return match(n)( |
| 9 | // clang-format off |
| 10 | pattern | 0 = [] { return 1; }, |
| 11 | pattern | _ = [n] { return n * factorial(n - 1); } |
| 12 | // clang-format on |
| 13 | ); |
| 14 | } |
| 15 | |
| 16 | static_assert(factorial(3) == 6); |
| 17 |
no test coverage detected