fork download
  1. #include <iostream>
  2. #include <set>
  3. #include <iterator>
  4. #include <tuple>
  5.  
  6. using namespace std;
  7.  
  8. struct keker{
  9.  
  10. int a;
  11. int b;
  12.  
  13. };
  14.  
  15. bool operator < (const keker& a, const keker& b)
  16. {
  17. return tie(a.a,a.b) < tie(b.a,b.b);
  18. }
  19.  
  20. int main(int argc, char const *argv[])
  21. {
  22.  
  23. set<keker> rofl;
  24.  
  25. keker k1,k2,k3,k4;
  26.  
  27. k1.a =1;
  28.  
  29. k2.a =2;
  30.  
  31. k3.a =3;
  32.  
  33. k4.a =4;
  34.  
  35.  
  36. rofl.insert(k1);
  37. rofl.insert(k2);
  38. rofl.insert(k3);
  39. rofl.insert(k4);
  40.  
  41. auto it = rofl.begin();
  42. cout << it->a <<endl;
  43. it++;
  44. cout << it->a <<endl;
  45. it++;
  46. cout << it->a <<endl;
  47. it++;
  48. cout << it->a <<endl;
  49.  
  50. return 0;
  51.  
  52. }
  53.  
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
1
2
3
4