As explained by @Anton Savin, the two lambdas have different types. Similarily to this s/o question, if you'd still really want to use only one template parameter type, you can do so by resorting to std::function<>
which was introduced in C++11. As I explained in another answer, it ensures your two function arguments have the same types:
#include <iostream>
#include <functional>
template <class A, class OP>
auto WhichOp2(A argument, OP firstOp, OP secondOp)->decltype(firstOp(argument)) {
return firstOp(argument) + secondOp(argument);
}
int main()
{
int d = WhichOp2(
2,
std::function<int(int)>([](int i){return i * 2; }),
std::function<int(int)>([](int i){return i * 3; })
);
std::cout << "result : " << d << std::endl;
}