title: STL list, delete all the odd numbers
body: <p>I am trying to learn how to work with STL and tried to write a function which will recieve a refference to a list and will try to delete all odd members.
  I am having a slight problem in my code.Here is my code</p>
  
  <pre><code>void removeOdds(list&lt;int&gt;&amp; myvector)
  {
      for(list&lt;int&gt;::iterator p=myvector.begin(); p !=myvector.end();p++)
      {
          if(*p%2 !=0)
          {
              list&lt;int&gt;::iterator temp=myvector.erase(p);
              p=temp;
              if(p !=myvector.begin())
                  p--;
          }
      }
  }
  </code></pre>
  
  <p>The problem that I am having is that If I pass a list containing 1 3 5 2 6 7 for example. After deleting 1, it obviously skips to 5, and does not look at 3.
  How can I fix this, because that p++ increments, and p-- does not happen because I am at the beginning.</p>