Let’s say I have following function:
int foo (int a)
{
return something;
}
How can I do something like this?
vector<int> v;
std::for_each( v.begin(), v.end(), std::bind1st(std::minus<int>(), foo) );
I want this to work like: for_each passes current element into the functor, functor calls foo and then subtracts the passed vector element and result of calling foo. Is it possible to make this using only std, not boost or self-written functors?
Well this is slightly horrible but in C++11…
less horrible way using lambdas