0

Modernize equality operators

This CL is pure clean-up and contains no functionality changes.
Depending on the files covered in the CL (since the CL was generated
using git cl split), it does a subset of the following:
- Remove unneeded operator!= declarations/definitions since C++20 can
  automatically derive those from operator==.
- Default operator== where this is equivalent to the current behavior.
- Default operator<=> where this is equivalent to the current
  behavior.

This CL was uploaded by git cl split.

R=dljames@chromium.org

Bug: 40256175
Change-Id: If9c5a170ffb29dc20a4e78a8b97fd901451369eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6513635
Auto-Submit: Jan Keitel <jkeitel@google.com>
Reviewed-by: Darryl James <dljames@chromium.org>
Commit-Queue: Jan Keitel <jkeitel@google.com>
Cr-Commit-Position: refs/heads/main@{#1456470}
This commit is contained in:
Jan Keitel
2025-05-06 11:18:57 -07:00
committed by Chromium LUCI CQ
parent 02852e5953
commit 7d2964dd55
4 changed files with 7 additions and 31 deletions
components

@ -44,24 +44,15 @@ class SESSIONS_EXPORT SessionID {
inline std::size_t operator()(SessionID id) const { return id.id(); }
};
friend bool operator==(const SessionID&, const SessionID&) = default;
friend auto operator<=>(const SessionID&, const SessionID&) = default;
private:
explicit constexpr SessionID(id_type id) : id_(id) {}
id_type id_;
};
inline bool operator==(SessionID lhs, SessionID rhs) {
return lhs.id() == rhs.id();
}
inline bool operator!=(SessionID lhs, SessionID rhs) {
return lhs.id() != rhs.id();
}
inline bool operator<(SessionID lhs, SessionID rhs) {
return lhs.id() < rhs.id();
}
// For use in gtest-based unit tests.
SESSIONS_EXPORT std::ostream& operator<<(std::ostream& out, SessionID id);