I have a set stores the keys which I want to delete in a map.
I tried the code blow, but it didn’t compile.
std::set<std::string> keys;
std::map<std::string, std::string> mymap;
....
for_each(keys.begin(), keys.end(), boost::bind(&std::map<std::string,
std::string>::erase,
&mymap, _1));
You cannot take the address of a Standard Library member function because the declarations of such member functions are unspecified (an implementation is permitted to add additional, optional parameters or add additional overloads to otherwise non-overloaded member functions, so long as the behavior is the same).
The easiest way to do what you are trying to do is:
If you have a compiler that supports lambda expressions, you might also consider:
If for some reason you really want to use
bind, you’ll need to write a function object to callerase: