fork(16) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <iterator>
  5.  
  6. struct X
  7. {
  8. X(int n) : n_(n) { }
  9. X(const X& rhs) : n_(rhs.n_) { }
  10. X& operator=(X&& rhs) { n_ = rhs.n_; std::cout << "=(X&&) "; }
  11. int n_;
  12. };
  13.  
  14. int main()
  15. {
  16. std::vector<X> v{2, 1, 8, 3, 4, 5, 6};
  17. v.erase(std::remove_if(std::make_move_iterator(std::begin(v)),
  18. std::make_move_iterator(std::end(v)),
  19. [] (const X& x) { return x.n_ & 1; }).base(),
  20. std::end(v));
  21. for (auto& x : v)
  22. std::cout << x.n_ << ' ';
  23. std::cout << '\n';
  24. }
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
=(X&&) =(X&&) =(X&&) 2 8 4 6