Hughes, James wrote:
I have a question for boost:binders out there... In the following scenario..(pseudocode)
Class Fred { typedef std::map
MyMap; MyMap Bert;
Save(MyMap::iterator pos) { ... }
SaveAll() { for_each(Bert.begin(), Bert.end(), bind(&Fred::Save, this, _1); }
};
The code wants to save all the data in the map. The bind, I was hoping, would simply call Save for all items in the map, passing in the iterator as the parameter, but I get a template compile fault on the bind. I've tried all sorts of combinations, checked boost docs, read the chapter in Beyond the C++ standard library, Googled etc, but just cannot figure out what I need to do here.
std::for_each passes the dereferenced iterator value to the function object. You'll need to at least change the signature of Save to: void Save( MyMap::value_type& val )... Jeff Flinn