From 4d1d5d6b209a6537c2d5441b813030eb852320fa Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 11 Dec 2020 12:30:13 +0800 Subject: [PATCH] Revise Utils::Version comparison operators --- src/base/utils/version.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/base/utils/version.h b/src/base/utils/version.h index 22952f7f6..d18df83e0 100644 --- a/src/base/utils/version.h +++ b/src/base/utils/version.h @@ -133,19 +133,15 @@ namespace Utils return (*this != ThisType {}); } - constexpr bool operator==(const ThisType &other) const + // TODO: remove manually defined operators and use compiler generated `operator<=>()` in C++20 + friend bool operator==(const ThisType &left, const ThisType &right) { - return (m_components == other.m_components); + return (left.m_components == right.m_components); } - constexpr bool operator<(const ThisType &other) const + friend bool operator<(const ThisType &left, const ThisType &right) { - return (m_components < other.m_components); - } - - constexpr bool operator>(const ThisType &other) const - { - return (m_components > other.m_components); + return (left.m_components < right.m_components); } template @@ -198,6 +194,12 @@ namespace Utils return !(left == right); } + template + constexpr bool operator>(const Version &left, const Version &right) + { + return (right < left); + } + template constexpr bool operator<=(const Version &left, const Version &right) {