title: Accessing for_each iterator from lambda
body: <p>Is it possible to access the std::for_each iterator, so I can erase the current element from an std::list using a lambda (as below)</p>
  
  <pre><code>typedef std::shared_ptr&lt;IEvent&gt;    EventPtr;
  std::list&lt;EventPtr&gt; EventQueue;
  EventType evt;
  ...
  
  std::for_each( 
      EventQueue.begin(), EventQueue.end(),
  
      [&amp;]( EventPtr pEvent )
      {
          if( pEvent-&gt;EventType() == evt.EventType() )
              EventQueue.erase( ???Iterator??? );
      }
  );
  </code></pre>
  
  <p>I've read about using [](typename T::value_type x){ delete x; } here on SO, but VS2010 doesn't seem to like this statement (underlines T as error source).</p>