From e33b0d4bb068873ed54116a540f9a498172d1a79 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 14 Sep 2020 15:15:43 +0200 Subject: [PATCH] Make QDateTime() unconditionally noexcept As proposed by Lars in code-review; its Data::Data() is in fact noexcept even when CanBeSmall is false. Task-number: QTBUG-86400 Change-Id: I351e4332660f5895fff34b950227cbb811fd9f81 Reviewed-by: Thiago Macieira --- src/corelib/time/qdatetime.cpp | 9 +++++---- src/corelib/time/qdatetime.h | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index af77a0ee26..05f0f37ee8 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -2984,7 +2984,7 @@ static QPair getDateTime(const QDateTimeData &d) QDateTime::Data member functions *****************************************************************************/ -inline QDateTime::Data::Data() +inline QDateTime::Data::Data() noexcept { // default-constructed data has a special exception: // it can be small even if CanBeSmall == false @@ -3327,12 +3327,13 @@ inline qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QT */ /*! - Constructs a null datetime (i.e. null date and null time). A null - datetime is invalid, since the date is invalid. + Constructs a null datetime. + + A null datetime is invalid, since its date and time are invalid. \sa isValid() */ -QDateTime::QDateTime() noexcept(Data::CanBeSmall) +QDateTime::QDateTime() noexcept { } diff --git a/src/corelib/time/qdatetime.h b/src/corelib/time/qdatetime.h index f35da36e30..4556895f10 100644 --- a/src/corelib/time/qdatetime.h +++ b/src/corelib/time/qdatetime.h @@ -244,7 +244,7 @@ class Q_CORE_EXPORT QDateTime CanBeSmall = sizeof(ShortData) * 8 > 50 }; - Data(); + Data() noexcept; Data(Qt::TimeSpec); Data(const Data &other); Data(Data &&other); @@ -262,7 +262,7 @@ class Q_CORE_EXPORT QDateTime }; public: - QDateTime() noexcept(Data::CanBeSmall); + QDateTime() noexcept; QDateTime(QDate date, QTime time, Qt::TimeSpec spec = Qt::LocalTime, int offsetSeconds = 0); #if QT_CONFIG(timezone) QDateTime(QDate date, QTime time, const QTimeZone &timeZone);