| 2 | #include <iostream> |
| 3 | |
| 4 | constexpr bool checkAndlogLarge(double value) |
| 5 | { |
| 6 | using namespace matchit; |
| 7 | |
| 8 | auto const square = [](auto &&v) |
| 9 | { return v * v; }; |
| 10 | Id<double> s; |
| 11 | return match(value)( |
| 12 | pattern | app(square, and_(_ > 1000, s)) = |
| 13 | [&] |
| 14 | { |
| 15 | std::cout << value << "^2 = " << *s << " > 1000!" << std::endl; |
| 16 | return true; |
| 17 | }, |
| 18 | pattern | _ = expr(false)); |
| 19 | } |
| 20 | |
| 21 | // comment out std::cout then uncomment this. |
| 22 | // static_assert(checkAndlogLarge(100)); |