diff --git a/src/util/semanticversion.h b/src/util/semanticversion.h index b7eb1ae3a2e..c8a9a9f276e 100644 --- a/src/util/semanticversion.h +++ b/src/util/semanticversion.h @@ -1,6 +1,7 @@ #pragma once #include +#include class QString; @@ -26,6 +27,9 @@ class SemanticVersion { friend constexpr std::strong_ordering operator<=>( const SemanticVersion&, const SemanticVersion&) noexcept; + friend constexpr bool operator==( + const SemanticVersion&, const SemanticVersion&) noexcept; + // Do not change the order because the synthesized comparison operators // depend on it! unsigned int majorVersion; @@ -36,9 +40,21 @@ class SemanticVersion { // you should not be able to create an invalid version easily from the outside constexpr SemanticVersion() : SemanticVersion(0, 0, 0){}; + // make tuple, which is used for the implementation of the comparison operators + constexpr std::tuple makeTuple() const { + return std::tie(majorVersion, minorVersion, patchVersion); + } }; +// TODO: replace with = default (synthesized) implementations once widely +// supported on target compilers. constexpr std::strong_ordering operator<=>( - const SemanticVersion&, const SemanticVersion&) noexcept = default; - + const SemanticVersion& lhs, const SemanticVersion& rhs) noexcept { + return lhs.makeTuple() <=> rhs.makeTuple(); +} + +constexpr bool operator==( + const SemanticVersion& lhs, const SemanticVersion& rhs) noexcept { + return lhs.makeTuple() == rhs.makeTuple(); +} } // namespace mixxx