Suppose you want to rewrite the following loop
struct Shape {
int rgb_color() const;
};
map<int, Shape*> id_to_shape;
vector<int> bright_colors;
for( map<int, Shape*>::iterator it=id_to_shape.begin(); it != id_to_shape.end(); ++it )
{
int color = it->second->rgb_color();
if (color_is_bright (color))
v.push_back(bright_colors);
}
Here follows a tour in ways that this loop could be expressed.