Make QPointer comparisons hidden friends
Reduces ADL noise. Change-Id: Id0aa4b32b7bb6d70ed9106b949452d895d9060a9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>bb10
parent
2516fc935c
commit
e356ab2c32
|
|
@ -89,49 +89,31 @@ public:
|
|||
|
||||
inline void clear()
|
||||
{ wp.clear(); }
|
||||
|
||||
#define DECLARE_COMPARE_SET(T1, A1, T2, A2) \
|
||||
friend bool operator==(T1, T2) \
|
||||
{ return A1 == A2; } \
|
||||
friend bool operator!=(T1, T2) \
|
||||
{ return A1 != A2; }
|
||||
|
||||
#define DECLARE_TEMPLATE_COMPARE_SET(T1, A1, T2, A2) \
|
||||
template <typename X> \
|
||||
friend bool operator==(T1, T2) noexcept \
|
||||
{ return A1 == A2; } \
|
||||
template <typename X> \
|
||||
friend bool operator!=(T1, T2) noexcept \
|
||||
{ return A1 != A2; }
|
||||
|
||||
DECLARE_TEMPLATE_COMPARE_SET(const QPointer &p1, p1.data(), const QPointer<X> &p2, p2.data())
|
||||
DECLARE_TEMPLATE_COMPARE_SET(const QPointer &p1, p1.data(), X *ptr, ptr)
|
||||
DECLARE_TEMPLATE_COMPARE_SET(X *ptr, ptr, const QPointer &p2, p2.data())
|
||||
DECLARE_COMPARE_SET(const QPointer &p1, p1.data(), std::nullptr_t, nullptr)
|
||||
DECLARE_COMPARE_SET(std::nullptr_t, nullptr, const QPointer &p2, p2.data())
|
||||
#undef DECLARE_COMPARE_SET
|
||||
#undef DECLARE_TEMPLATE_COMPARE_SET
|
||||
};
|
||||
template <class T> Q_DECLARE_TYPEINFO_BODY(QPointer<T>, Q_MOVABLE_TYPE);
|
||||
|
||||
template <class T>
|
||||
inline bool operator==(const T *o, const QPointer<T> &p)
|
||||
{ return o == p.operator->(); }
|
||||
|
||||
template<class T>
|
||||
inline bool operator==(const QPointer<T> &p, const T *o)
|
||||
{ return p.operator->() == o; }
|
||||
|
||||
template <class T>
|
||||
inline bool operator==(T *o, const QPointer<T> &p)
|
||||
{ return o == p.operator->(); }
|
||||
|
||||
template<class T>
|
||||
inline bool operator==(const QPointer<T> &p, T *o)
|
||||
{ return p.operator->() == o; }
|
||||
|
||||
template<class T>
|
||||
inline bool operator==(const QPointer<T> &p1, const QPointer<T> &p2)
|
||||
{ return p1.operator->() == p2.operator->(); }
|
||||
|
||||
template <class T>
|
||||
inline bool operator!=(const T *o, const QPointer<T> &p)
|
||||
{ return o != p.operator->(); }
|
||||
|
||||
template<class T>
|
||||
inline bool operator!= (const QPointer<T> &p, const T *o)
|
||||
{ return p.operator->() != o; }
|
||||
|
||||
template <class T>
|
||||
inline bool operator!=(T *o, const QPointer<T> &p)
|
||||
{ return o != p.operator->(); }
|
||||
|
||||
template<class T>
|
||||
inline bool operator!= (const QPointer<T> &p, T *o)
|
||||
{ return p.operator->() != o; }
|
||||
|
||||
template<class T>
|
||||
inline bool operator!= (const QPointer<T> &p1, const QPointer<T> &p2)
|
||||
{ return p1.operator->() != p2.operator->() ; }
|
||||
|
||||
template<typename T>
|
||||
QPointer<T>
|
||||
qPointerFromVariant(const QVariant &variant)
|
||||
|
|
|
|||
|
|
@ -340,7 +340,7 @@ QMacPasteboard::setMimeData(QMimeData *mime_src, DataRequestType dataRequestType
|
|||
mime = mime_src;
|
||||
|
||||
QList<QMacInternalPasteboardMime*> availableConverters = QMacInternalPasteboardMime::all(mime_type);
|
||||
if (mime != 0) {
|
||||
if (mime != nullptr) {
|
||||
clear_helper();
|
||||
QStringList formats = mime_src->formats();
|
||||
|
||||
|
|
|
|||
|
|
@ -708,14 +708,14 @@ void tst_QTextCursor::checkFrame1()
|
|||
{
|
||||
QCOMPARE(cursor.position(), 0);
|
||||
QPointer<QTextFrame> frame = cursor.insertFrame(QTextFrameFormat());
|
||||
QVERIFY(frame != 0);
|
||||
QVERIFY(frame != nullptr);
|
||||
|
||||
QTextFrame *root = frame->parentFrame();
|
||||
QVERIFY(root != 0);
|
||||
QVERIFY(root != nullptr);
|
||||
|
||||
QCOMPARE(frame->firstPosition(), 1);
|
||||
QCOMPARE(frame->lastPosition(), 1);
|
||||
QVERIFY(frame->parentFrame() != 0);
|
||||
QVERIFY(frame->parentFrame() != nullptr);
|
||||
QCOMPARE(root->childFrames().size(), 1);
|
||||
|
||||
QCOMPARE(cursor.position(), 1);
|
||||
|
|
|
|||
Loading…
Reference in New Issue