Merge pull request #13953 from Chocobo1/cmp

Migrate away from deprecated QVariant comparison operators
This commit is contained in:
Mike Tzou
2020-12-13 11:49:52 +08:00
committed by GitHub
4 changed files with 72 additions and 51 deletions

View File

@@ -84,6 +84,11 @@ bool BitTorrent::operator!=(const InfoHash &left, const InfoHash &right)
return !(left == right);
}
bool BitTorrent::operator<(const InfoHash &left, const InfoHash &right)
{
return static_cast<lt::sha1_hash>(left) < static_cast<lt::sha1_hash>(right);
}
uint BitTorrent::qHash(const InfoHash &key, const uint seed)
{
return ::qHash((std::hash<lt::sha1_hash> {})(key), seed);

View File

@@ -61,6 +61,7 @@ namespace BitTorrent
bool operator==(const InfoHash &left, const InfoHash &right);
bool operator!=(const InfoHash &left, const InfoHash &right);
bool operator<(const InfoHash &left, const InfoHash &right);
uint qHash(const InfoHash &key, uint seed);
}

View File

@@ -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 <typename StringClassWithSplitMethod>
@@ -198,6 +194,12 @@ namespace Utils
return !(left == right);
}
template <typename T, std::size_t N, std::size_t Mandatory>
constexpr bool operator>(const Version<T, N, Mandatory> &left, const Version<T, N, Mandatory> &right)
{
return (right < left);
}
template <typename T, std::size_t N, std::size_t Mandatory>
constexpr bool operator<=(const Version<T, N, Mandatory> &left, const Version<T, N, Mandatory> &right)
{