Reland "Replace bool operator== for VersionType in sanitizer_mac.h" (#135276)
Fixes error: ISO C++20 considers use of overloaded operator '==' (with operand types 'MacosVersion' and 'MacosVersion') to be ambiguous despite there being a unique best viable function [-Werror,-Wambiguous-reversed-operator]. This converts the comparison operator from a non-symmetric operator (const VersionBase<VersionType>& (as "this") and const VersionType &). into a symmetric operator Relands #135068 Co-authored-by: Ivan Tadeu Ferreira Antunes Filho <antunesi@google.com>
This commit is contained in:
parent
9aff19e7a3
commit
862e7190c9
@ -37,9 +37,6 @@ struct VersionBase {
|
||||
|
||||
VersionBase(u16 major, u16 minor) : major(major), minor(minor) {}
|
||||
|
||||
bool operator==(const VersionType &other) const {
|
||||
return major == other.major && minor == other.minor;
|
||||
}
|
||||
bool operator>=(const VersionType &other) const {
|
||||
return major > other.major ||
|
||||
(major == other.major && minor >= other.minor);
|
||||
@ -47,6 +44,12 @@ struct VersionBase {
|
||||
bool operator<(const VersionType &other) const { return !(*this >= other); }
|
||||
};
|
||||
|
||||
template <typename VersionType>
|
||||
bool operator==(const VersionBase<VersionType> &self,
|
||||
const VersionBase<VersionType> &other) {
|
||||
return self.major == other.major && self.minor == other.minor;
|
||||
}
|
||||
|
||||
struct MacosVersion : VersionBase<MacosVersion> {
|
||||
MacosVersion(u16 major, u16 minor) : VersionBase(major, minor) {}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user