title: Is it possible to erase elements of a std::list in a c++11 for each loop
body: <p>I want to use the new C++11 for each loop to iterate over all elements of a list and erase certains elements. For example</p>
  
  <pre><code>std::list&lt;int&gt; myList;
  myList.push_back(1); 
  myList.push_back(13);
  myList.push_back(9);
  myList.push_back(4);
  
  for(int element : myList) {
      if(element &gt; 5) {
          //Do something with the element
  
          //erase the element
      }else{
          //Do something else with the element
      }
  }
  </code></pre>
  
  <p>Is it possible to do this using the for each loop or do I have to go back to iterators to achive this?</p>