diff options
author | Tatiana Borisova <tatiana.borisova@qt.io> | 2024-04-16 15:22:14 +0200 |
---|---|---|
committer | Tatiana Borisova <tatiana.borisova@qt.io> | 2024-04-26 20:11:14 +0200 |
commit | 2606c0966669fe76300d4c818f8c05e778aacd23 (patch) | |
tree | 8e35c66076aefe79399073148f1cffeed0c17386 /src/corelib | |
parent | 913442a75a269048bea7968aa2708888e10611c4 (diff) |
QBitArray: use new comparison helper macros
Replace public friend operators operator==(), operator!=() of
QBitArray to friend method comparesEqual() and
Q_DECLARE_EQUALITY_COMPARABLE macro.
Task-number: QTBUG-120304
Change-Id: I6b47111c144016b3aa05f01c8035c32d164291ad
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/compat/removed_api.cpp | 1 | ||||
-rw-r--r-- | src/corelib/tools/qbitarray.cpp | 10 | ||||
-rw-r--r-- | src/corelib/tools/qbitarray.h | 13 |
3 files changed, 18 insertions, 6 deletions
diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index 9b7ad48384..c8cc969f81 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -929,6 +929,7 @@ QUrl QUrl::fromEncoded(const QByteArray &input, ParsingMode mode) #endif // QT_CORE_REMOVED_SINCE(6, 7) #if QT_CORE_REMOVED_SINCE(6, 8) +#include "qbitarray.h" // inlined API #include "qbytearray.h" // inlined API diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp index e311fee51f..e4276d383d 100644 --- a/src/corelib/tools/qbitarray.cpp +++ b/src/corelib/tools/qbitarray.cpp @@ -23,6 +23,8 @@ QT_BEGIN_NAMESPACE \ingroup shared \reentrant + \compares equality + A QBitArray is an array that gives access to individual bits and provides operators (\l{operator&()}{AND}, \l{operator|()}{OR}, \l{operator^()}{XOR}, and \l{operator~()}{NOT}) that work on @@ -499,17 +501,17 @@ quint32 QBitArray::toUInt32(QSysInfo::Endian endianness, bool *ok) const noexcep fast and never fails. */ -/*! \fn bool QBitArray::operator==(const QBitArray &other) const +/*! \fn bool QBitArray::operator==(const QBitArray &lhs, const QBitArray &rhs) - Returns \c true if \a other is equal to this bit array; otherwise + Returns \c true if \a lhs is equal to \a rhs bit array; otherwise returns \c false. \sa operator!=() */ -/*! \fn bool QBitArray::operator!=(const QBitArray &other) const +/*! \fn bool QBitArray::operator!=(const QBitArray &lhs, const QBitArray &rhs) - Returns \c true if \a other is not equal to this bit array; + Returns \c true if \a lhs is not equal to \a rhs bit array; otherwise returns \c false. \sa operator==() diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h index 4f99e693eb..b9c36b5320 100644 --- a/src/corelib/tools/qbitarray.h +++ b/src/corelib/tools/qbitarray.h @@ -116,8 +116,10 @@ public: QBitArray operator~() const; #endif - inline bool operator==(const QBitArray &other) const { return d == other.d; } - inline bool operator!=(const QBitArray &other) const { return d != other.d; } +#if QT_CORE_REMOVED_SINCE(6, 8) + inline bool operator==(const QBitArray &other) const { return comparesEqual(d, other.d); } + inline bool operator!=(const QBitArray &other) const { return !operator==(other); } +#endif bool fill(bool aval, qsizetype asize = -1) { *this = QBitArray((asize < 0 ? this->size() : asize), aval); return true; } @@ -134,6 +136,13 @@ public: typedef QByteArray::DataPointer DataPtr; inline DataPtr &data_ptr() { return d.data_ptr(); } inline const DataPtr &data_ptr() const { return d.data_ptr(); } + +private: + friend bool comparesEqual(const QBitArray &lhs, const QBitArray &rhs) noexcept + { + return lhs.d == rhs.d; + } + Q_DECLARE_EQUALITY_COMPARABLE(QBitArray) }; class QT6_ONLY(Q_CORE_EXPORT) QBitRef |