fork download
  1. #include <vector>
  2. #include <iostream>
  3. #include <algorithm>
  4.  
  5. template<class T>
  6. void printAll(const T& v) {
  7. for(const auto& e : v) {
  8. std::cout << e << " ";
  9. }
  10. std::cout << "\n";
  11. }
  12.  
  13. int main() {
  14. std::vector<int> v { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  15. printAll(v);
  16.  
  17. v.erase(
  18. std::remove_if(
  19. std::begin(v), std::end(v)
  20. , [](const decltype(v)::value_type& e) {
  21. return (e % 2) == 0;
  22. }
  23. ), std::end(v)
  24. );
  25. printAll(v);
  26. }
  27.  
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
0 1 2 3 4 5 6 7 8 9 
1 3 5 7 9