From ff04c24184c103aab9e56f8adac70784db9ef6c5 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Tue, 23 May 2023 12:56:23 +0200 Subject: [PATCH] QTime: use new comparison helper macros The unit-tests were already ported to the new comparison helper functions from QTestPrivate. Task-number: QTBUG-104111 Change-Id: I23267fd457547b2705e821e7666130f5f9c019d5 Reviewed-by: Edward Welbourne --- src/corelib/time/qdatetime.cpp | 12 ++++++------ src/corelib/time/qdatetime.h | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 3651aaa9d7..6b260a36ec 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -2236,38 +2236,38 @@ int QTime::msecsTo(QTime t) const /*! - \fn bool QTime::operator==(QTime lhs, QTime rhs) + \fn bool QTime::operator==(const QTime &lhs, const QTime &rhs) Returns \c true if \a lhs is equal to \a rhs; otherwise returns \c false. */ /*! - \fn bool QTime::operator!=(QTime lhs, QTime rhs) + \fn bool QTime::operator!=(const QTime &lhs, const QTime &rhs) Returns \c true if \a lhs is different from \a rhs; otherwise returns \c false. */ /*! - \fn bool QTime::operator<(QTime lhs, QTime rhs) + \fn bool QTime::operator<(const QTime &lhs, const QTime &rhs) Returns \c true if \a lhs is earlier than \a rhs; otherwise returns \c false. */ /*! - \fn bool QTime::operator<=(QTime lhs, QTime rhs) + \fn bool QTime::operator<=(const QTime &lhs, const QTime &rhs) Returns \c true if \a lhs is earlier than or equal to \a rhs; otherwise returns \c false. */ /*! - \fn bool QTime::operator>(QTime lhs, QTime rhs) + \fn bool QTime::operator>(const QTime &lhs, const QTime &rhs) Returns \c true if \a lhs is later than \a rhs; otherwise returns \c false. */ /*! - \fn bool QTime::operator>=(QTime lhs, QTime rhs) + \fn bool QTime::operator>=(const QTime &lhs, const QTime &rhs) Returns \c true if \a lhs is later than or equal to \a rhs; otherwise returns \c false. diff --git a/src/corelib/time/qdatetime.h b/src/corelib/time/qdatetime.h index 6183daa5a1..0301a4fdde 100644 --- a/src/corelib/time/qdatetime.h +++ b/src/corelib/time/qdatetime.h @@ -235,12 +235,12 @@ private: constexpr inline int ds() const { return mds == -1 ? 0 : mds; } int mds; - friend constexpr bool operator==(QTime lhs, QTime rhs) { return lhs.mds == rhs.mds; } - friend constexpr bool operator!=(QTime lhs, QTime rhs) { return lhs.mds != rhs.mds; } - friend constexpr bool operator< (QTime lhs, QTime rhs) { return lhs.mds < rhs.mds; } - friend constexpr bool operator<=(QTime lhs, QTime rhs) { return lhs.mds <= rhs.mds; } - friend constexpr bool operator> (QTime lhs, QTime rhs) { return lhs.mds > rhs.mds; } - friend constexpr bool operator>=(QTime lhs, QTime rhs) { return lhs.mds >= rhs.mds; } + friend constexpr bool comparesEqual(const QTime &lhs, const QTime &rhs) noexcept + { return lhs.mds == rhs.mds; } + friend constexpr Qt::strong_ordering + compareThreeWay(const QTime &lhs, const QTime &rhs) noexcept + { return Qt::compareThreeWay(lhs.mds, rhs.mds); } + Q_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE(QTime) friend class QDateTime; friend class QDateTimePrivate;