QDate: use new comparison helper macros
Comparison with std::chrono types is also supported due to implicit QDate constructors, which were made constexpr and noexcept in the previous patch. The unit-tests were already ported to the new comparison helper functions from QTestPrivate. Task-number: QTBUG-104111 Change-Id: Ib6b1122af9eaf2cb2c9db768150a31cf3bcadcc0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>bb10
parent
96f494bf92
commit
a6f4e55b4d
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#define QDATETIME_H
|
||||
|
||||
#include <QtCore/qcalendar.h>
|
||||
#include <QtCore/qcompare.h>
|
||||
#include <QtCore/qnamespace.h>
|
||||
#include <QtCore/qshareddata.h>
|
||||
#include <QtCore/qstring.h>
|
||||
|
|
@ -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 &);
|
||||
|
|
|
|||
Loading…
Reference in New Issue