vector<int>::iterator i = a.begin(); while( i!=a.end()) { if((int)(*i) == del_element) i=a.erase(i); else i++; };