Use std::bindthrough std::bind1standstd::bind2nd
std::for_each(list.begin(), list.end(),
std::bind2nd(std::mem_fun(&Interface::do_something),1)
);
Unfortunately, the standard does not help for the two versions of the arguments, and you need to write your own:
struct MyFunctor
{
void (Interface::*func)(int,int);
int a;
int b;
MyFunctor(void (Interface::*f)(int,int), int a, int b): func(f), a(a), b(b) {}
void operator()(Interface* i){ (i->*func)(a,b);}
};
std::for_each(list.begin(), list.end(),
MyFunctor(&Interface::do_func, 1, 2)
);
source
share