fork download
  1.  
  2. #include <unordered_set>
  3.  
  4. struct RIGHT128 {
  5. uint64_t X;
  6. uint64_t Y;
  7.  
  8. RIGHT128() : X(0), Y(0) {};
  9. RIGHT128(const uint64_t& x, const uint64_t& y) : X(x), Y(y) {};
  10. RIGHT128(const RIGHT128& other) {
  11. X = other.X;
  12. Y = other.Y;
  13. };
  14.  
  15. RIGHT128& operator=(const RIGHT128& other) {
  16. X = other.X;
  17. Y = other.Y;
  18. return *this;
  19. };
  20.  
  21. bool operator==(const RIGHT128& other) {
  22. if (X == other.X && Y == other.Y)
  23. return true;
  24. return false;
  25. };
  26.  
  27. bool operator<(const RIGHT128& other) {
  28. if (X < other.X)
  29. return true;
  30. else if (X == other.X && Y == other.Y)
  31. return true;
  32.  
  33. return false;
  34. };
  35.  
  36. // this could be moved in to std::hash<Point>::operator()
  37. size_t operator()(const RIGHT128& RIGHT128ToHash) const noexcept {
  38. size_t hash = RIGHT128ToHash.X + 10 * RIGHT128ToHash.Y;
  39. return hash;
  40. };
  41.  
  42. };
  43.  
  44. namespace std {
  45. template<> struct hash<RIGHT128>
  46. {
  47. std::size_t operator()(const RIGHT128& p) const noexcept
  48. {
  49. return p(p);
  50. }
  51. };
  52. }
  53.  
  54. int main()
  55. {
  56. // no need to specify the hasher if std::hash<Point> exists
  57. std::unordered_set<RIGHT128> p;
  58. return 0;
  59. }
Success #stdin #stdout 0s 5276KB
stdin
Standard input is empty
stdout
Standard output is empty