Make QScopedPointer comparison operators hidden friends
Reduce overload resolution noise. Fixes: QTBUG-87979 Change-Id: I52f96e016ffaf1b4f2235a05c1175c5af3eebe36 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
739e7dd191
commit
04549f68ab
@ -183,21 +183,20 @@ QT_BEGIN_NAMESPACE
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn template <typename T, typename Cleanup> bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
|
\fn template <typename T, typename Cleanup> bool QScopedPointer<T, Cleanup>::operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
|
||||||
|
|
||||||
Returns \c true if \a ptr1 and \a ptr2 refer to the same pointer.
|
Returns \c true if \a lhs and \a rhs refer to the same pointer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn template <typename T, typename Cleanup> bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
|
\fn template <typename T, typename Cleanup> bool QScopedPointer<T, Cleanup>::operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
|
||||||
|
|
||||||
Returns \c true if \a lhs and \a rhs refer to distinct pointers.
|
Returns \c true if \a lhs and \a rhs refer to distinct pointers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn template <typename T, typename Cleanup> bool operator==(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
|
\fn template <typename T, typename Cleanup> bool QScopedPointer<T, Cleanup>::operator==(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
|
||||||
\relates QScopedPointer
|
|
||||||
\since 5.8
|
\since 5.8
|
||||||
|
|
||||||
Returns \c true if \a lhs refers to \nullptr.
|
Returns \c true if \a lhs refers to \nullptr.
|
||||||
@ -206,8 +205,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn template <typename T, typename Cleanup> bool operator==(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
|
\fn template <typename T, typename Cleanup> bool QScopedPointer<T, Cleanup>::operator==(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
|
||||||
\relates QScopedPointer
|
|
||||||
\since 5.8
|
\since 5.8
|
||||||
|
|
||||||
Returns \c true if \a rhs refers to \nullptr.
|
Returns \c true if \a rhs refers to \nullptr.
|
||||||
@ -216,8 +214,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn template <typename T, typename Cleanup> bool operator!=(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
|
\fn template <typename T, typename Cleanup> bool QScopedPointer<T, Cleanup>::operator!=(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
|
||||||
\relates QScopedPointer
|
|
||||||
\since 5.8
|
\since 5.8
|
||||||
|
|
||||||
Returns \c true if \a lhs refers to a valid (i.e. non-null) pointer.
|
Returns \c true if \a lhs refers to a valid (i.e. non-null) pointer.
|
||||||
@ -226,8 +223,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn template <typename T, typename Cleanup> bool operator!=(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
|
\fn template <typename T, typename Cleanup> bool QScopedPointer<T, Cleanup>::operator!=(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
|
||||||
\relates QScopedPointer
|
|
||||||
\since 5.8
|
\since 5.8
|
||||||
|
|
||||||
Returns \c true if \a rhs refers to a valid (i.e. non-null) pointer.
|
Returns \c true if \a rhs refers to a valid (i.e. non-null) pointer.
|
||||||
@ -268,8 +264,8 @@ QT_BEGIN_NAMESPACE
|
|||||||
\sa isNull()
|
\sa isNull()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \fn template <typename T, typename Cleanup> void QScopedPointer<T, Cleanup>::swap(QScopedPointer<T, Cleanup> &other)
|
/*! \fn template <typename T, typename Cleanup> void QScopedPointer<T, Cleanup>::swap(QScopedPointer<T, Cleanup> &lhs, QScopedPointer<T, Cleanup> &rhs)
|
||||||
Swap this pointer with \a other.
|
Swaps \a lhs with \a rhs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -165,6 +165,39 @@ public:
|
|||||||
|
|
||||||
typedef T *pointer;
|
typedef T *pointer;
|
||||||
|
|
||||||
|
friend bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs) noexcept
|
||||||
|
{
|
||||||
|
return lhs.data() == rhs.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
friend bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs) noexcept
|
||||||
|
{
|
||||||
|
return lhs.data() != rhs.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
friend bool operator==(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t) noexcept
|
||||||
|
{
|
||||||
|
return lhs.isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
friend bool operator==(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs) noexcept
|
||||||
|
{
|
||||||
|
return rhs.isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
friend bool operator!=(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t) noexcept
|
||||||
|
{
|
||||||
|
return !lhs.isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
friend bool operator!=(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs) noexcept
|
||||||
|
{
|
||||||
|
return !rhs.isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
friend void swap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2) noexcept
|
||||||
|
{ p1.swap(p2); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
T *d;
|
T *d;
|
||||||
|
|
||||||
@ -172,46 +205,6 @@ private:
|
|||||||
Q_DISABLE_COPY(QScopedPointer)
|
Q_DISABLE_COPY(QScopedPointer)
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class Cleanup>
|
|
||||||
inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs) noexcept
|
|
||||||
{
|
|
||||||
return lhs.data() == rhs.data();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T, class Cleanup>
|
|
||||||
inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs) noexcept
|
|
||||||
{
|
|
||||||
return lhs.data() != rhs.data();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T, class Cleanup>
|
|
||||||
inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t) noexcept
|
|
||||||
{
|
|
||||||
return lhs.isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T, class Cleanup>
|
|
||||||
inline bool operator==(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs) noexcept
|
|
||||||
{
|
|
||||||
return rhs.isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T, class Cleanup>
|
|
||||||
inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t) noexcept
|
|
||||||
{
|
|
||||||
return !lhs.isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T, class Cleanup>
|
|
||||||
inline bool operator!=(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs) noexcept
|
|
||||||
{
|
|
||||||
return !rhs.isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T, class Cleanup>
|
|
||||||
inline void swap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2) noexcept
|
|
||||||
{ p1.swap(p2); }
|
|
||||||
|
|
||||||
template <typename T, typename Cleanup = QScopedPointerArrayDeleter<T> >
|
template <typename T, typename Cleanup = QScopedPointerArrayDeleter<T> >
|
||||||
class QScopedArrayPointer : public QScopedPointer<T, Cleanup>
|
class QScopedArrayPointer : public QScopedPointer<T, Cleanup>
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user