title: std::for_each on container of pointers
body: <p>In some class I have a <code>hash_set</code> of pointers:</p>
  
  <pre><code>std::hash_set&lt;GameObject*&gt; gameObjects;
  </code></pre>
  
  <p>I wish to iterate through all of them and call update. With iterators this would be like this:</p>
  
  <pre><code>for(std::hash_set&lt;GameObject*&gt;::iterator it = gameObjects.begin(), it_end = gameObjects.end(); it != it_end; ++it)
  {
  (*it)-&gt;update();
  }
  </code></pre>
  
  <p>This is too much code; I want to use <code>std::for_each</code>.</p>
  
  <p>If I had just <code>hash_set&lt;GameObject&gt;</code>, this would look like this:</p>
  
  <pre><code>std::for_each(gameObjects.begin(), gameObjects.end(), std::mem_fun_ref(&amp;GameObject::update));
  </code></pre>
  
  <p>or, if update was expecting a parameter, </p>
  
  <pre><code>std::for_each(gameObjects.begin(), gameObject.end(), std::bind2nd(std::mem_fun_ref(&amp;GameObject::update), deltaTime));
  </code></pre>
  
  <p>How would these both expressions look for the <code>hash_set</code> of pointers?</p>
  
  <p>I am using MS VisualStudio 2010.</p>