fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. struct foo {
  9. string anulat;
  10. int value;
  11. };
  12.  
  13. int main() {
  14. vector<foo> v {
  15. {"Test1", 10},
  16. {"Yes", 20},
  17. {"Test2", 5},
  18. {"Yes", 10},
  19. {"Yes", 1},
  20. {"Test3", 0}
  21. };
  22.  
  23. cout << "--- Before:" << endl;
  24. for(const auto& item : v) cout << item.anulat << " : " << item.value << endl;
  25.  
  26. v.erase(remove_if(v.begin(),v.end(),[](auto& item) {return item.anulat=="Yes";}), v.end());
  27.  
  28. cout << "--- After:" << endl;
  29. for(const auto& item : v) cout << item.anulat << " : " << item.value << endl;
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0s 4580KB
stdin
Standard input is empty
stdout
--- Before:
Test1 : 10
Yes : 20
Test2 : 5
Yes : 10
Yes : 1
Test3 : 0
--- After:
Test1 : 10
Test2 : 5
Test3 : 0