Use default operators generated/synthesized by compiler

This commit is contained in:
Chocobo1 2022-04-02 13:34:52 +08:00
parent 10ee1ab7a2
commit 7612d5d0ef
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
15 changed files with 4 additions and 76 deletions

View file

@ -134,11 +134,6 @@ namespace
}
};
bool operator==(const QString &arg, const BoolOption &option)
{
return (option == arg);
}
// Option with string value. May not have a shortcut
struct StringOption : protected Option
{
@ -181,11 +176,6 @@ namespace
}
};
bool operator==(const QString &arg, const StringOption &option)
{
return (option == arg);
}
// Option with integer value. May not have a shortcut
class IntOption : protected StringOption
{
@ -233,11 +223,6 @@ namespace
}
};
bool operator==(const QString &arg, const IntOption &option)
{
return (option == arg);
}
// Option that is explicitly set to true or false, and whose value is undefined when unspecified.
// May not have a shortcut.
class TriStateBoolOption : protected Option
@ -316,11 +301,6 @@ namespace
bool m_defaultValue;
};
bool operator==(const QString &arg, const TriStateBoolOption &option)
{
return (option == arg);
}
constexpr const BoolOption SHOW_HELP_OPTION {"help", 'h'};
constexpr const BoolOption SHOW_VERSION_OPTION {"version", 'v'};
#if defined(DISABLE_GUI) && !defined(Q_OS_WIN)

View file

@ -120,8 +120,3 @@ bool BitTorrent::operator==(const BitTorrent::InfoHash &left, const BitTorrent::
{
return (static_cast<InfoHash::WrappedType>(left) == static_cast<InfoHash::WrappedType>(right));
}
bool BitTorrent::operator!=(const BitTorrent::InfoHash &left, const BitTorrent::InfoHash &right)
{
return !(left == right);
}

View file

@ -90,7 +90,6 @@ namespace BitTorrent
std::size_t qHash(const TorrentID &key, std::size_t seed = 0);
bool operator==(const InfoHash &left, const InfoHash &right);
bool operator!=(const InfoHash &left, const InfoHash &right);
}
Q_DECLARE_METATYPE(BitTorrent::TorrentID)

View file

@ -135,11 +135,6 @@ namespace BitTorrent
return (left.uniqueID() == right.uniqueID());
}
bool operator!=(const Peer &left, const Peer &right)
{
return !(left == right);
}
std::size_t qHash(const Peer &key, const std::size_t seed)
{
return qHash(key.uniqueID(), seed);

View file

@ -64,7 +64,6 @@ namespace BitTorrent
};
bool operator==(const Peer &left, const Peer &right);
bool operator!=(const Peer &left, const Peer &right);
std::size_t qHash(const Peer &key, std::size_t seed = 0);
// *Basic* Bittorrent tracker implementation

View file

@ -144,12 +144,6 @@ bool operator==(const Digest32<N> &left, const Digest32<N> &right)
== static_cast<typename Digest32<N>::UnderlyingType>(right));
}
template <int N>
bool operator!=(const Digest32<N> &left, const Digest32<N> &right)
{
return !(left == right);
}
template <int N>
bool operator<(const Digest32<N> &left, const Digest32<N> &right)
{

View file

@ -107,11 +107,6 @@ public:
return (*left == *right);
}
friend constexpr bool operator!=(const Iterator &left, const Iterator &right)
{
return !(left == right);
}
private:
IndexType m_index;
};

View file

@ -41,11 +41,6 @@ bool Net::operator==(const ProxyConfiguration &left, const ProxyConfiguration &r
&& (left.hostnameLookupEnabled == right.hostnameLookupEnabled);
}
bool Net::operator!=(const ProxyConfiguration &left, const ProxyConfiguration &right)
{
return !(left == right);
}
using namespace Net;
ProxyConfigurationManager *ProxyConfigurationManager::m_instance = nullptr;

View file

@ -57,7 +57,6 @@ namespace Net
bool hostnameLookupEnabled = true;
};
bool operator==(const ProxyConfiguration &left, const ProxyConfiguration &right);
bool operator!=(const ProxyConfiguration &left, const ProxyConfiguration &right);
class ProxyConfigurationManager final : public QObject
{

View file

@ -342,11 +342,6 @@ bool operator==(const Path &lhs, const Path &rhs)
return (lhs.data().compare(rhs.data(), CASE_SENSITIVITY) == 0);
}
bool operator!=(const Path &lhs, const Path &rhs)
{
return !(lhs == rhs);
}
Path operator/(const Path &lhs, const Path &rhs)
{
if (rhs.isEmpty())

View file

@ -95,7 +95,6 @@ private:
Q_DECLARE_METATYPE(Path)
bool operator==(const Path &lhs, const Path &rhs);
bool operator!=(const Path &lhs, const Path &rhs);
Path operator+(const Path &lhs, QStringView rhs);
QDataStream &operator<<(QDataStream &out, const Path &path);

View file

@ -167,11 +167,6 @@ namespace RSS
return (left.m_dataPtr == right.m_dataPtr) // optimization
|| (*(left.m_dataPtr) == *(right.m_dataPtr));
}
bool operator!=(const AutoDownloadRule &left, const AutoDownloadRule &right)
{
return !(left == right);
}
}
using namespace RSS;

View file

@ -108,6 +108,4 @@ namespace RSS
QSharedDataPointer<AutoDownloadRuleData> m_dataPtr;
};
bool operator!=(const AutoDownloadRule &left, const AutoDownloadRule &right);
}

View file

@ -124,13 +124,12 @@ namespace Utils
return res;
}
// TODO: remove manually defined operators and use compiler generated `operator<=>()` in C++20
friend bool operator==(const ThisType &left, const ThisType &right)
friend constexpr bool operator==(const ThisType &left, const ThisType &right)
{
return (left.m_components == right.m_components);
}
friend bool operator<(const ThisType &left, const ThisType &right)
friend constexpr bool operator<(const ThisType &left, const ThisType &right)
{
return (left.m_components < right.m_components);
}
@ -159,12 +158,6 @@ namespace Utils
std::array<int, N> m_components {{}};
};
template <int N, int Mandatory>
constexpr bool operator!=(const Version<N, Mandatory> &left, const Version<N, Mandatory> &right)
{
return !(left == right);
}
template <int N, int Mandatory>
constexpr bool operator>(const Version<N, Mandatory> &left, const Version<N, Mandatory> &right)
{

View file

@ -67,12 +67,9 @@ struct PeerEndpoint
{
BitTorrent::PeerAddress address;
QString connectionType; // matches return type of `PeerInfo::connectionType()`
};
bool operator==(const PeerEndpoint &left, const PeerEndpoint &right)
{
return (left.address == right.address) && (left.connectionType == right.connectionType);
}
friend bool operator==(const PeerEndpoint &left, const PeerEndpoint &right) = default;
};
std::size_t qHash(const PeerEndpoint &peerEndpoint, const std::size_t seed = 0)
{