| 41 | } |
| 42 | |
| 43 | double get_area(const Shape &shape) |
| 44 | { |
| 45 | using namespace matchit; |
| 46 | Id<Circle> c; |
| 47 | Id<Rectangle> r; |
| 48 | return match(shape)( |
| 49 | pattern | |
| 50 | as<Circle>(c) = [&] |
| 51 | { return 3.14 * (*c).radius * (*c).radius; }, |
| 52 | pattern | as<Rectangle>(r) = [&] |
| 53 | { return (*r).width * (*r).height; }); |
| 54 | } |
| 55 | |
| 56 | int32_t main() |
| 57 | { |