| 4 | #include <cstdint> |
| 5 | |
| 6 | class MedicalRecordNumber { |
| 7 | public: |
| 8 | MedicalRecordNumber() = default; |
| 9 | explicit MedicalRecordNumber(uint64_t mrn) |
| 10 | : mMRN{mrn} |
| 11 | {} |
| 12 | |
| 13 | // #A The initial member functions |
| 14 | bool operator==(const MedicalRecordNumber& other) const |
| 15 | { |
| 16 | return mMRN == other.mMRN; |
| 17 | } |
| 18 | |
| 19 | bool operator!=(const MedicalRecordNumber& other) const |
| 20 | { |
| 21 | return !(*this == other); |
| 22 | } |
| 23 | |
| 24 | // #B The additional overloads for uint64_t |
| 25 | friend bool operator==(const MedicalRecordNumber& rec, |
| 26 | const uint64_t& num) |
| 27 | { |
| 28 | return rec.mMRN == num; |
| 29 | } |
| 30 | |
| 31 | friend bool operator!=(const MedicalRecordNumber& rec, |
| 32 | const uint64_t& num) |
| 33 | { |
| 34 | return !(rec == num); |
| 35 | } |
| 36 | |
| 37 | // #C The additional overloads with swapped arguments for uint64_t |
| 38 | friend bool operator==(const uint64_t& num, |
| 39 | const MedicalRecordNumber& rec) |
| 40 | { |
| 41 | return (rec == num); |
| 42 | } |
| 43 | |
| 44 | friend bool operator!=(const uint64_t& num, |
| 45 | const MedicalRecordNumber& rec) |
| 46 | { |
| 47 | return !(rec == num); |
| 48 | } |
| 49 | |
| 50 | private: |
| 51 | uint64_t mMRN; |
| 52 | }; |
| 53 | |
| 54 | int main() |
| 55 | { |
nothing calls this directly
no outgoing calls
no test coverage detected