fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4.  
  5. int main(){
  6. std::vector<int> v{4,4,4,4,4,1,2,3,4,4,3,5,7,4,3,5,76,3,4,6,4,3,1,3,4};
  7. //v gets populated...
  8. int toberemoved=4;
  9.  
  10. auto itr = std::remove_if(v.begin(),v.end(), [&](int a){return a == toberemoved;});
  11.  
  12. v.erase(itr,v.end());
  13. for(auto& x : v){
  14. std::cout << x << ',';
  15. }
  16. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
1,2,3,3,5,7,3,5,76,3,6,3,1,3,