First page Back Continue Last page Overview Graphics
For_each iterator in C++
#include <algorithm>
typedef std::map<std::string, int> StringIntMap;
void f (StringIntMap::value_type& v)
{
std::cout << v.first << ":" << v.second << std::endl;
}
StringIntMap m;
m["Fred"] = 5;
m["Bob"] = 3;
for_each(m.begin(), m.end(), f);
Notes: