fork download
  1. #include <iostream>
  2. #include <utility>
  3.  
  4. using namespace std;
  5.  
  6. typedef std::pair<int, double> MyID;
  7.  
  8. struct Num {} constexpr num;
  9.  
  10. auto &operator,(MyID &x, Num)
  11. {
  12. return x.first;
  13. }
  14.  
  15. auto &operator%(MyID &x, Num)
  16. {
  17. return x.first;
  18. }
  19.  
  20. auto &numf(MyID &x)
  21. {
  22. return x.first;
  23. }
  24.  
  25. int main()
  26. {
  27. MyID p{42, 0.5};
  28. cout << (p,num) << endl;
  29. cout << p%num << endl;
  30. cout << numf(p) << endl;
  31. }
  32.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
42
42
42