How to erase multiple elements from std::vector<> by index using erase function?
<p>I have a vector <code>a</code> storing values <code>[0 1 2 3 5]</code> and other vector <code>removelist</code> storing the indexes to be removed <code>[0 1 2]</code> in order to leave <code>[3 5]</code> at the end. When I'm implementing the following code, it would remove items unexpectedly since the vector <code>a</code> will be changing order during the process. Is there any way for me to achieve my target?</p>

<pre><code> for (int i = 0; i&lt;removelist.size() ; i++)     
    a.erase(a.begin() + removelist[i]);
</code></pre>