Skip to content

v0.4.1

Choose a tag to compare

@sentomk sentomk released this 06 Nov 12:24
· 412 commits to main since this release

Add predicate pattern (pred) for user-defined callable matching

auto is_even = pred([](int x){ return x % 2 == 0; });
auto is_pos  = pred([](int x){ return x > 0; });

auto out = match(5)
    .when(is_even && is_pos >> []{ return "even positive"; })
    .when(!is_even >> []{ return "odd"; })
    .otherwise([]{ return "other"; });
std::cout << out; // "odd"