Hide comparison of QHostAddress with SpecialAddress from ADL

Make global operators hidden friends. No change to the member-operators.

Task-number: QTBUG-87976
Change-Id: If7b08a30700d4e2f1a304d4b6cc4b5d02ee5e251
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
bb10
Volker Hilsheimer 2020-10-30 13:37:20 +01:00
parent 91140eb726
commit abc5b75d7f
2 changed files with 8 additions and 9 deletions

View File

@ -1272,8 +1272,7 @@ size_t qHash(const QHostAddress &key, size_t seed) noexcept
}
/*!
\fn bool operator==(QHostAddress::SpecialAddress lhs, const QHostAddress &rhs)
\relates QHostAddress
\fn bool QHostAddress::operator==(QHostAddress::SpecialAddress lhs, const QHostAddress &rhs)
Returns \c true if special address \a lhs is the same as host address \a rhs;
otherwise returns \c false.
@ -1282,8 +1281,7 @@ size_t qHash(const QHostAddress &key, size_t seed) noexcept
*/
/*!
\fn bool operator!=(QHostAddress::SpecialAddress lhs, const QHostAddress &rhs)
\relates QHostAddress
\fn bool QHostAddress::operator!=(QHostAddress::SpecialAddress lhs, const QHostAddress &rhs)
\since 5.9
Returns \c false if special address \a lhs is the same as host address \a rhs;

View File

@ -148,6 +148,12 @@ public:
static QPair<QHostAddress, int> parseSubnet(const QString &subnet);
friend Q_NETWORK_EXPORT size_t qHash(const QHostAddress &key, size_t seed) noexcept;
friend bool operator ==(QHostAddress::SpecialAddress lhs, const QHostAddress &rhs)
{ return rhs == lhs; }
friend bool operator!=(QHostAddress::SpecialAddress lhs, const QHostAddress &rhs)
{ return rhs != lhs; }
protected:
friend class QHostAddressPrivate;
QExplicitlySharedDataPointer<QHostAddressPrivate> d;
@ -155,11 +161,6 @@ protected:
Q_DECLARE_OPERATORS_FOR_FLAGS(QHostAddress::ConversionMode)
Q_DECLARE_SHARED(QHostAddress)
inline bool operator ==(QHostAddress::SpecialAddress address1, const QHostAddress &address2)
{ return address2 == address1; }
inline bool operator!=(QHostAddress::SpecialAddress lhs, const QHostAddress &rhs)
{ return rhs != lhs; }
#ifndef QT_NO_DEBUG_STREAM
Q_NETWORK_EXPORT QDebug operator<<(QDebug, const QHostAddress &);
#endif