fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <functional>
  5. using namespace std::placeholders;
  6. struct Foo {
  7. bool condition;
  8. };
  9. int main()
  10. {
  11. std::vector<Foo> myVector = {{false}, {true}, {false}, {true}, {true}};
  12.  
  13. myVector.erase(
  14. remove_if(myVector.begin(), myVector.end(), std::bind(&Foo::condition, _1))
  15. , myVector.end());
  16.  
  17. for(auto i = myVector.begin(); i!=myVector.end(); ++i)
  18. std::cout << std::boolalpha << i->condition << '\n';
  19. }
  20.  
Success #stdin #stdout 0s 2960KB
stdin
Standard input is empty
stdout
false
false