I am looking for a way to create a binary operation between two predicate functions. This is my predicate function declaration:
template <typename T>
using Predicate = std::function<bool(T const&)>;
I am looking for a way to 'concat' two predicate functions into one:
template <typename T>
static Predicate<T> andPredicate(Predicate<T> a, Predicate<T> b) {
// ???
}
Expected behaviour:
Predicate<int> a = [](int a) { return a < 5; };
Predicate<int> b = [](int a) { return a > 0; };
Predicate<int> c = andPredicate(a, b); // a < 5 && a > 0
int number = 3;
bool result = c(number);
Is something like this possible in C++?