| 63 | // }; |
| 64 | |
| 65 | class Integer |
| 66 | { |
| 67 | int num_; |
| 68 | |
| 69 | public: |
| 70 | Integer(int n) : num_{ n } {} |
| 71 | auto GetNum() const noexcept { return num_; } |
| 72 | // 不定义operator<=>,只允许进行相等的比较。 |
| 73 | bool operator==(const Integer &) const = default; |
| 74 | // C++23也可以用bool operator==(this Integer, Integer) = default; |
| 75 | // 来进行值传递,总之要保持两个参数的类型一样。 |
| 76 | }; |
| 77 | |
| 78 | template<> |
| 79 | struct std::hash<Integer> |
nothing calls this directly
no outgoing calls
no test coverage detected