From 0f19f09a3211933895b7c9b2ff559d8db5afefc9 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Mon, 6 Mar 2023 20:59:30 +0200 Subject: [PATCH] fix version comparisons --- loader/include/Geode/utils/VersionInfo.hpp | 36 +++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/loader/include/Geode/utils/VersionInfo.hpp b/loader/include/Geode/utils/VersionInfo.hpp index d9df8c88..af63f04c 100644 --- a/loader/include/Geode/utils/VersionInfo.hpp +++ b/loader/include/Geode/utils/VersionInfo.hpp @@ -56,8 +56,8 @@ namespace geode { constexpr bool operator>(VersionTag const& other) const { if (value == other.value) { if (number && other.number) return number > other.number; - if (number) return true; - if (other.number) return false; + if (number) return false; + if (other.number) return true; return false; } return value > other.value; @@ -65,8 +65,8 @@ namespace geode { constexpr bool operator>=(VersionTag const& other) const { if (value == other.value) { if (number && other.number) return number >= other.number; - if (number) return true; - if (other.number) return false; + if (number) return false; + if (other.number) return true; return true; } return value >= other.value; @@ -77,6 +77,34 @@ namespace geode { std::string toString() const; }; + constexpr bool operator<(std::optional const& a, std::optional const& b) { + if (a && b) return a < b; + if (a) return true; + if (b) return false; + return false; + } + + constexpr bool operator<=(std::optional const& a, std::optional const& b) { + if (a && b) return a <= b; + if (a) return true; + if (b) return false; + return true; + } + + constexpr bool operator>(std::optional const& a, std::optional const& b) { + if (a && b) return a > b; + if (a) return false; + if (b) return true; + return false; + } + + constexpr bool operator>=(std::optional const& a, std::optional const& b) { + if (a && b) return a >= b; + if (a) return false; + if (b) return true; + return true; + } + /** * Class representing version information. Uses a limited subset of SemVer; * identifiers are restricted to a few predefined ones, and only one