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:

committed by
Chromium LUCI CQ

parent
02852e5953
commit
7d2964dd55
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);
|
||||
|
||||
|
@ -40,9 +40,6 @@ class COMPONENT_EXPORT(TAB_GROUPS) TabGroupVisualData {
|
||||
bool operator==(const TabGroupVisualData& other) const {
|
||||
return title_ == other.title_ && color_ == other.color_;
|
||||
}
|
||||
bool operator!=(const TabGroupVisualData& other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
void SetTitle(const std::u16string& title) { title_ = title; }
|
||||
|
||||
|
@ -33,13 +33,8 @@ class COMPONENT_EXPORT(TAB_GROUPS) TokenId {
|
||||
|
||||
TokenId<T>& operator=(const TokenId<T>& other) = default;
|
||||
|
||||
bool operator==(const TokenId<T>& other) const {
|
||||
return token_ == other.token_;
|
||||
}
|
||||
bool operator!=(const TokenId<T>& other) const { return !(*this == other); }
|
||||
bool operator<(const TokenId<T>& other) const {
|
||||
return token_ < other.token_;
|
||||
}
|
||||
friend bool operator==(const TokenId<T>&, const TokenId<T>&) = default;
|
||||
friend auto operator<=>(const TokenId<T>&, const TokenId<T>&) = default;
|
||||
|
||||
const base::Token& token() const { return token_; }
|
||||
|
||||
|
@ -114,15 +114,8 @@ class SupportsHandles<T>::Handle {
|
||||
ObjectType* Get() const;
|
||||
|
||||
// Handles are comparable and sortable.
|
||||
bool operator==(const Handle& other) const {
|
||||
return raw_value_ == other.raw_value_;
|
||||
}
|
||||
bool operator!=(const Handle& other) const {
|
||||
return raw_value_ != other.raw_value_;
|
||||
}
|
||||
bool operator<(const Handle& other) const {
|
||||
return raw_value_ < other.raw_value_;
|
||||
}
|
||||
friend bool operator==(const Handle&, const Handle&) = default;
|
||||
friend auto operator<=>(const Handle&, const Handle&) = default;
|
||||
|
||||
// Explicitly provide the null value and handle.
|
||||
static constexpr int32_t NullValue = 0;
|
||||
|
Reference in New Issue
Block a user