I have a vector with 3 tuples in it. I want to delete all tuples with the second value 4. this is my code:
int main() {
tuple thing1 = make_tuple(1, 4, 2, 2);
tuple thing2 = make_tuple(2, 2, 2, 2);
tuple thing3 = make_tuple(3, 4, 2, 2);
vector<thing> things = {thing1, thing2, thing3};
int index = 0;
for (vector<thing>::iterator it = things.begin(); it != things.end(); ++it) {
if (get<1>(*it) == 4) {
things.erase(things.begin()+index);
} else {
index++;
}
}
}
But this code delete all of them. can anyone help me please ? Thank you so mush :)