I am trying to call a member function on each object in a vector, with a specified parameter, and I would like the call to be polymorphic. I believe the function vstuff shown below achieves this. But can vstuff be modified to take a vector< shared_ptr < Base> > without using boost::bind?
class Base{
virtual double stuff(double t);
}
//and some derived classes overriding stuff
//then in some code
vector<double> vstuff(double t, vector<Base*> things)
{
vector<double> vals;
vals.resize(things.size());
transform(things.begin(), things.end(), vals.begin(), std::bind2nd(std::mem_fun(&Base::stuff),t));
return vals;
}
I know that shared_ptr s require mem_fn instead of mem_fun , but I have not succeeded in making mem_fn work with the bind2nd I need to pass in the parameter t, so I wonder whether or not it is feasible.. ?