fork(1) download
  1. #include <iostream>
  2. #include <tuple>
  3. using namespace std;
  4.  
  5. struct S { int a; char b; double c; };
  6. auto const S_fields = [](S const& z) -> auto { return tie(z.a, z.b, z.c); };
  7.  
  8. bool operator == (S const& x, S const& y)
  9. {
  10. return S_fields(x) == S_fields(y);
  11. }
  12. bool operator < (S const& x, S const& y)
  13. {
  14. return S_fields(x) < S_fields(y);
  15. }
  16.  
  17. int main() {
  18. S p { 1,2,3 }, q {1,2,4};
  19. cout << (p == p) << (p == q) << (p < p) << (p < q) << (q < p) << endl;
  20. return 0;
  21. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
10010