diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index d1b07df07d..3651aaa9d7 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -1555,14 +1555,14 @@ qint64 QDate::daysTo(QDate d) const /*! - \fn bool QDate::operator==(QDate lhs, QDate rhs) + \fn bool QDate::operator==(const QDate &lhs, const QDate &rhs) Returns \c true if \a lhs and \a rhs represent the same day, otherwise \c false. */ /*! - \fn bool QDate::operator!=(QDate lhs, QDate rhs) + \fn bool QDate::operator!=(const QDate &lhs, const QDate &rhs) Returns \c true if \a lhs and \a rhs represent distinct days; otherwise returns \c false. @@ -1571,26 +1571,26 @@ qint64 QDate::daysTo(QDate d) const */ /*! - \fn bool QDate::operator<(QDate lhs, QDate rhs) + \fn bool QDate::operator<(const QDate &lhs, const QDate &rhs) Returns \c true if \a lhs is earlier than \a rhs; otherwise returns \c false. */ /*! - \fn bool QDate::operator<=(QDate lhs, QDate rhs) + \fn bool QDate::operator<=(const QDate &lhs, const QDate &rhs) Returns \c true if \a lhs is earlier than or equal to \a rhs; otherwise returns \c false. */ /*! - \fn bool QDate::operator>(QDate lhs, QDate rhs) + \fn bool QDate::operator>(const QDate &lhs, const QDate &rhs) Returns \c true if \a lhs is later than \a rhs; otherwise returns \c false. */ /*! - \fn bool QDate::operator>=(QDate lhs, QDate rhs) + \fn bool QDate::operator>=(const QDate &lhs, const QDate &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 bbfc0ec9fc..6183daa5a1 100644 --- a/src/corelib/time/qdatetime.h +++ b/src/corelib/time/qdatetime.h @@ -6,6 +6,7 @@ #define QDATETIME_H #include +#include #include #include #include @@ -170,12 +171,13 @@ private: friend class QDateTime; friend class QDateTimePrivate; - friend constexpr bool operator==(QDate lhs, QDate rhs) { return lhs.jd == rhs.jd; } - friend constexpr bool operator!=(QDate lhs, QDate rhs) { return lhs.jd != rhs.jd; } - friend constexpr bool operator< (QDate lhs, QDate rhs) { return lhs.jd < rhs.jd; } - friend constexpr bool operator<=(QDate lhs, QDate rhs) { return lhs.jd <= rhs.jd; } - friend constexpr bool operator> (QDate lhs, QDate rhs) { return lhs.jd > rhs.jd; } - friend constexpr bool operator>=(QDate lhs, QDate rhs) { return lhs.jd >= rhs.jd; } + friend constexpr bool comparesEqual(const QDate &lhs, const QDate &rhs) noexcept + { return lhs.jd == rhs.jd; } + friend constexpr Qt::strong_ordering + compareThreeWay(const QDate &lhs, const QDate &rhs) noexcept + { return Qt::compareThreeWay(lhs.jd, rhs.jd); } + Q_DECLARE_STRONGLY_ORDERED_LITERAL_TYPE(QDate) + #ifndef QT_NO_DATASTREAM friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, QDate); friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QDate &);