Our compose function has a problem—it only works with lambdas that receive one argument. So, what do we do if we want to compose functions with multiple arguments?
Let's take the following example—given two lambdas, multiply and increment:
auto increment = [](const int value) { return value + 1; };
auto multiply = [](const int first, const int second){ return first * second; };
Can we obtain a lambda that increments the result of the multiplication?
Unfortunately, we cannot use our compose function since it assumes that both functions have one parameter:
template <class F, class G>
auto compose(F f, G g){
return [=](auto value){return f(g(value));};
}
So, what are our options?