title: Remove vector elements based on the index
body: <p>I wanted to remove the elements of the vector based on the index, say all the even indexed elements. 
  I have read about the erase remove idiom but can't see how to apply it.
  This is what I tried:</p>
  
  <pre><code>    vector&lt;int&gt; line;
      line.reserve(10);
      for(int i=0;i&lt;10;++i)
      {
        line.push_back(i+1);
      }
      for(unsigned int i=0;i&lt;line.size();++i)
      {
        //remove the even indexed elements
        if(i%2 == 0)
        {
          remove(line.begin(),line.end(),line[i]);
        }
      }
  line.erase( line.begin(),line.end() );
  </code></pre>
  
  <p>This erases the entire vector. I was hoping to only remove the elements that had been marked by the remove algorithm.</p>
  
  <p>Then I tried this</p>
  
  <pre><code>for(unsigned int i=0;i&lt;line.size();++i)
      {
        //remove the even indexed elements
        if(i%2 == 0)
        {
          line.erase( remove(line.begin(),line.end(),line[i]),line.end() );
        }
      }
  </code></pre>
  
  <p>This again doesn't work as there is a problem while removing, the indices seem to shift whilst iterating over the vector.
  What should be the correct approach to accomplish this.</p>