I have a container of pointers which I want to iterate over, calling a member function which has a parameter that is a reference. How do I do this with STL?
My current solution is to use boost::bind, and boost::ref for the parameter.
// Given:
// void Renderable::render(Graphics& g)
//
// There is a reference, g, in scope with the call to std::for_each
//
std::for_each(
sprites.begin(),
sprites.end(),
boost::bind(&Renderable::render, _1, boost::ref(g))
);
A related question (from which I derived my current solution from) is boost::bind with functions that have parameters that are references. This specifically asks how to do this with boost. I am asking how it would be done without boost.