Reputation: 77
Is it possible to pass a function definition as an arguement and if so what is the syntax for that? If it is not, what would be the reason? I would like to do something like:
double arr1[10], arr2[10];
std::equal(arr1, &(arr1[5]), arr2, (bool(*)(double a, double b){return a == -b;});
Upvotes: 3
Views: 98
Reputation: 477060
You can use lambdas for that:
std::equal(arr1, arr1 + 5, arr2, [](double a, double b) { return a == -b; });
Upvotes: 5