| 11 | { return app(get<I>, pat); }; |
| 12 | |
| 13 | void sample() |
| 14 | { |
| 15 | struct Point |
| 16 | { |
| 17 | uint32_t x; |
| 18 | uint32_t y; |
| 19 | }; |
| 20 | constexpr auto s = Point{1U, 1U}; |
| 21 | |
| 22 | match(s)( |
| 23 | // clang-format off |
| 24 | pattern | and_(app(&Point::x, 10U), app(&Point::y, 20U)) = []{}, |
| 25 | pattern | and_(app(&Point::y, 10U), app(&Point::x, 20U)) = []{}, // order doesn't matter |
| 26 | pattern | app(&Point::x, 10U) = []{}, |
| 27 | pattern | _ = []{} // clang-format on |
| 28 | ); |
| 29 | |
| 30 | using PointTuple = std::tuple<uint32_t, uint32_t>; |
| 31 | constexpr auto t = PointTuple{1U, 2U}; |
| 32 | |
| 33 | match(t)( |
| 34 | // clang-format off |
| 35 | pattern | and_(appGet<0>(10U), appGet<1>(20U)) = []{}, |
| 36 | pattern | and_(appGet<1>(10U), appGet<0>(20U)) = []{}, // order doesn't matter |
| 37 | pattern | appGet<0>(10U) = []{}, |
| 38 | pattern | _ = []{} // clang-format on |
| 39 | ); |
| 40 | } |
| 41 | |
| 42 | int32_t main() |
| 43 | { |