| 123456789101112131415161718192021222324252627282930313233343536 |
- //
- // match.cpp
- // case-matcher
- //
- // Created by Sam Jaffe on 9/10/16.
- //
- #include <iostream>
- #include "match.hpp"
- struct example {
- example(long in) : i(in) {}
- example(example const &) : i(0xDEADBEEF) {}
- long i;
- };
- bool operator==(example const & a, example const & b) {
- return a.i == b.i;
- }
- int main() {
- example const ex{1};
- bool b{true};
-
- match(ex, b) {
- with(example{1}, false) {
- std::cout << "Match 1" << std::endl;
- }
- with(example{0xDEADBEEF}, matcher::any) {
- std::cout << "Match 2" << std::endl;
- }
- with(matcher::any, true) {
- std::cout << "Match 3" << std::endl;
- }
- }
- }
|