I have a vector a storing values [0 1 2 3 5] and other vector removelist storing the indexes to be removed [0 1 2] in order to leave [3 5] at the end. When I'm implementing the following code, it would remove items unexpectedly since the vector a will be changing order during the process. Is there any way for me to achieve my target?
for (int i = 0; i<removelist.size() ; i++)
a.erase(a.begin() + removelist[i]);
removelistordered?avector is ordered as he removes it by indices not by values. But his example is buggy (there is no index 5 in a vector with size 5)