fork(2) download
  1. #include <iostream>
  2. #include <list>
  3. #include <utility>
  4. using namespace std;
  5.  
  6. int main() {
  7. list<int> l({2, 1, 3, 4, 5});
  8. auto it = l.begin(), jt = ++l.begin();
  9.  
  10. cout << *it << '\t' << *jt << '\n';
  11. l.sort();
  12. cout << *it << '\t' << *jt << '\n';
  13. swap(*it, *jt);
  14. cout << *it << '\t' << *jt << '\n';
  15. return 0;
  16. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
2	1
2	1
1	2