Browse Source

Use default operators generated/synthesized by compiler

adaptive-webui-19844
Chocobo1 3 years ago
parent
commit
7612d5d0ef
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 20
      src/app/cmdoptions.cpp
  2. 5
      src/base/bittorrent/infohash.cpp
  3. 1
      src/base/bittorrent/infohash.h
  4. 5
      src/base/bittorrent/tracker.cpp
  5. 1
      src/base/bittorrent/tracker.h
  6. 6
      src/base/digest32.h
  7. 5
      src/base/indexrange.h
  8. 5
      src/base/net/proxyconfigurationmanager.cpp
  9. 1
      src/base/net/proxyconfigurationmanager.h
  10. 5
      src/base/path.cpp
  11. 1
      src/base/path.h
  12. 5
      src/base/rss/rss_autodownloadrule.cpp
  13. 2
      src/base/rss/rss_autodownloadrule.h
  14. 11
      src/base/utils/version.h
  15. 7
      src/gui/properties/peerlistwidget.cpp

20
src/app/cmdoptions.cpp

@ -134,11 +134,6 @@ namespace @@ -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 @@ -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 @@ -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 @@ -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)

5
src/base/bittorrent/infohash.cpp

@ -120,8 +120,3 @@ bool BitTorrent::operator==(const BitTorrent::InfoHash &left, const BitTorrent:: @@ -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);
}

1
src/base/bittorrent/infohash.h

@ -90,7 +90,6 @@ namespace BitTorrent @@ -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)

5
src/base/bittorrent/tracker.cpp

@ -135,11 +135,6 @@ namespace BitTorrent @@ -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);

1
src/base/bittorrent/tracker.h

@ -64,7 +64,6 @@ namespace BitTorrent @@ -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

6
src/base/digest32.h

@ -144,12 +144,6 @@ bool operator==(const Digest32<N> &left, const Digest32<N> &right) @@ -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)
{

5
src/base/indexrange.h

@ -107,11 +107,6 @@ public: @@ -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;
};

5
src/base/net/proxyconfigurationmanager.cpp

@ -41,11 +41,6 @@ bool Net::operator==(const ProxyConfiguration &left, const ProxyConfiguration &r @@ -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;

1
src/base/net/proxyconfigurationmanager.h

@ -57,7 +57,6 @@ namespace Net @@ -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
{

5
src/base/path.cpp

@ -342,11 +342,6 @@ bool operator==(const Path &lhs, const Path &rhs) @@ -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())

1
src/base/path.h

@ -95,7 +95,6 @@ private: @@ -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);

5
src/base/rss/rss_autodownloadrule.cpp

@ -167,11 +167,6 @@ namespace RSS @@ -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;

2
src/base/rss/rss_autodownloadrule.h

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

11
src/base/utils/version.h

@ -124,13 +124,12 @@ namespace Utils @@ -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 @@ -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)
{

7
src/gui/properties/peerlistwidget.cpp

@ -67,12 +67,9 @@ struct PeerEndpoint @@ -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)
{

Loading…
Cancel
Save