fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. struct A {
  6. int val;
  7.  
  8. bool operator<(const A& other) const {
  9. std::cout << "operator\n";
  10. return val < other.val;
  11. }
  12.  
  13. A() = default;
  14. A(A&& a) : val(a.val) {
  15. std::cout << "move ctor\n";
  16. }
  17. A &operator=(A&& a) {
  18. val = a.val;
  19. std::cout << "move assign\n";
  20. }
  21. };
  22.  
  23. void swap(A& a, A& b) {
  24. std::cout << "foo\n";
  25. std::swap(a.val, b.val);
  26. }
  27.  
  28. int main()
  29. {
  30. std::vector<A> a(2);
  31. a[0].val = 10;
  32. a[1].val = -1;
  33.  
  34. std::sort(a.begin(), a.end());
  35. }
Success #stdin #stdout 0s 2964KB
stdin
Standard input is empty
stdout
operator
move ctor
move assign