title: converting a for loop to a std::for_each
body: <p>I've got this for loop:</p>
  
  <pre><code>    std::vector&lt;itemPtr&gt;::iterator it;
      for(it=items.begin(); it!=items.end(); ++it)
      {
          investigators.addToLeaderInventory(*it);
      }
  </code></pre>
  
  <p>I'd like to convert it to something like this:</p>
  
  <pre><code>std::for_each(items.begin(), items.end(), investigators.addToLeaderInventory);
  </code></pre>
  
  <p>However, that line doesn't compile.  g++ shows me this:</p>
  
  <pre><code>error: no matching function for call to
  ‘for_each(__gnu_cxx::__normal_iterator&lt;std::tr1::shared_ptr&lt;yarl::item::Item&gt;*,
  std::vector&lt;std::tr1::shared_ptr&lt;yarl::item::Item&gt;,  
  std::allocator&lt;std::tr1::shared_ptr&lt;yarl::item::Item&gt; &gt; &gt; &gt;,  
  __gnu_cxx::__normal_iterator&lt;std::tr1::shared_ptr&lt;yarl::item::Item&gt;*,  
  std::vector&lt;std::tr1::shared_ptr&lt;yarl::item::Item&gt;,   
  std::allocator&lt;std::tr1::shared_ptr&lt;yarl::item::Item&gt; &gt; &gt; &gt;, &lt;unresolved overloaded
  function type&gt;)’  
  /usr/include/c++/4.4/bits/stl_algo.h:4194: note: candidates are: _Funct  
  std::for_each(_IIter, _IIter, _Funct) [with _IIter =  
  __gnu_cxx::__normal_iterator&lt;std::tr1::shared_ptr&lt;yarl::item::Item&gt;*,   
  std::vector&lt;std::tr1::shared_ptr&lt;yarl::item::Item&gt;,   
  std::allocator&lt;std::tr1::shared_ptr&lt;yarl::item::Item&gt; &gt; &gt; &gt;, _Funct = void 
  (yarl::party::Party::*)(yarl::itemPtr)]
  </code></pre>
  
  <p>Hard to read, to say the least.  I imagine the solution is pretty simple, but I can't figure out what g++ is complaining about.  The signature of <code>investigators.addToLeaderInventory()</code> is this:</p>
  
  <pre><code>void ClassName::addToLeaderInventory(itemPtr item);
  </code></pre>
  
  <p>which should work with a <code>for_each</code>, shouldn't it?  What should I change?</p>