Listing 1: Function object ShowNextShape.

class ShowNextShape
{
  public:
    ShowNextShape(int lp, int ss) 
      : Layout(lp), Shown(ss){}
    void operator()(shape* s)
      { 
       //Compute new position based on layout policy
         s->draw(position);
       // Update ShapesAlreadyShown
    }
  private:
    LayoutPolicy        Layout;
    ShapesAlreadyShown& Shown;
};
 ...
for_each(shapes.begin(),
         shapes.end(),
         ShowNextShape(layout,AlreadyShown));