fix version comparisons

This commit is contained in:
HJfod 2023-03-06 20:59:30 +02:00
parent ed02c8a893
commit 0f19f09a32

View file

@ -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<VersionTag> const& a, std::optional<VersionTag> const& b) {
if (a && b) return a < b;
if (a) return true;
if (b) return false;
return false;
}
constexpr bool operator<=(std::optional<VersionTag> const& a, std::optional<VersionTag> const& b) {
if (a && b) return a <= b;
if (a) return true;
if (b) return false;
return true;
}
constexpr bool operator>(std::optional<VersionTag> const& a, std::optional<VersionTag> const& b) {
if (a && b) return a > b;
if (a) return false;
if (b) return true;
return false;
}
constexpr bool operator>=(std::optional<VersionTag> const& a, std::optional<VersionTag> 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