| 7 | #include <string> |
| 8 | |
| 9 | struct Address { |
| 10 | std::string city; |
| 11 | std::string street; |
| 12 | uint32_t street_no; |
| 13 | |
| 14 | auto operator<=>(const Address& rhs) const |
| 15 | { |
| 16 | // #A Sort city and street using their <=> |
| 17 | if(const auto& cmp = city <=> rhs.city; cmp != 0) { |
| 18 | return cmp; |
| 19 | } else if(const auto& scmp = street <=> rhs.street; |
| 20 | scmp != 0) { |
| 21 | return scmp; |
| 22 | } |
| 23 | |
| 24 | // #B Next, sort street_no ascending |
| 25 | return rhs.street_no <=> street_no; |
| 26 | } |
| 27 | |
| 28 | // #C The default should be good enough here |
| 29 | bool operator==(const Address&) const = default; |
| 30 | }; |
| 31 | |
| 32 | int main() |
| 33 | { |
nothing calls this directly
no outgoing calls
no test coverage detected