fork download
  1. #include <algorithm>
  2. #include <functional>
  3. #include <iostream>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. struct gameObject{
  9. bool value;
  10. bool getDestroyed() const { return value; }
  11. };
  12.  
  13.  
  14. int main() {
  15. vector<gameObject> gameObjects = {gameObject{true}, gameObject{false}, gameObject{false}};
  16.  
  17. cout << gameObjects.size() << endl;
  18.  
  19. gameObjects.erase(remove_if(gameObjects.begin(), gameObjects.end(), mem_fn(&gameObject::getDestroyed)), end(gameObjects));
  20.  
  21. cout << gameObjects.size() << endl;
  22. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
3
2