diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2022-05-23 15:55:42 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2022-06-08 18:41:01 +0200 |
commit | 720de98824cf8243df6c191a5c5d0bf98d05a142 (patch) | |
tree | da5c95a4bdd1c95838612a948ad57c14dd32c9f7 | |
parent | 02b11e0623ed795061a84602aaa1dc54b6460d72 (diff) |
QDateTime::Data, QTimeZone: rule-of-five and noexcept
CodeChecker noted that both QDateTime::Data and QTimeZone have
incomplete rule-of-five method sets; and two of the former's methods
should be noexcept. Marc tells me the copy constructor can be
noexcept. Added the missing methods and noexcepts.
Change-Id: I8ddaa86207320606a890e90bd2b1593ee82f5a4a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r-- | src/corelib/time/qdatetime.cpp | 6 | ||||
-rw-r--r-- | src/corelib/time/qdatetime.h | 7 | ||||
-rw-r--r-- | src/corelib/time/qtimezone.cpp | 9 | ||||
-rw-r--r-- | src/corelib/time/qtimezone.h | 1 |
4 files changed, 17 insertions, 6 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 189c474bfd..2bb925c60b 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -2980,7 +2980,7 @@ inline QDateTime::Data::Data(Qt::TimeSpec spec) } } -inline QDateTime::Data::Data(const Data &other) +inline QDateTime::Data::Data(const Data &other) noexcept : d(other.d) { if (!isShort()) { @@ -2997,7 +2997,7 @@ inline QDateTime::Data::Data(const Data &other) } } -inline QDateTime::Data::Data(Data &&other) +inline QDateTime::Data::Data(Data &&other) noexcept : d(other.d) { // reset the other to a short state @@ -3006,7 +3006,7 @@ inline QDateTime::Data::Data(Data &&other) other.d = dummy.d; } -inline QDateTime::Data &QDateTime::Data::operator=(const Data &other) +inline QDateTime::Data &QDateTime::Data::operator=(const Data &other) noexcept { if (d == other.d) return *this; diff --git a/src/corelib/time/qdatetime.h b/src/corelib/time/qdatetime.h index 79ae281774..08f0a1a533 100644 --- a/src/corelib/time/qdatetime.h +++ b/src/corelib/time/qdatetime.h @@ -286,9 +286,10 @@ class Q_CORE_EXPORT QDateTime Data() noexcept; Data(Qt::TimeSpec); - Data(const Data &other); - Data(Data &&other); - Data &operator=(const Data &other); + Data(const Data &other) noexcept; + Data(Data &&other) noexcept; + Data &operator=(const Data &other) noexcept; + Data &operator=(Data &&other) noexcept { swap(other); return *this; } ~Data(); void swap(Data &other) noexcept diff --git a/src/corelib/time/qtimezone.cpp b/src/corelib/time/qtimezone.cpp index 3b357cb455..c57e9e77fb 100644 --- a/src/corelib/time/qtimezone.cpp +++ b/src/corelib/time/qtimezone.cpp @@ -387,6 +387,15 @@ QTimeZone::QTimeZone(const QTimeZone &other) } /*! + Move constructor of this from \a other. +*/ + +QTimeZone::QTimeZone(QTimeZone &&other) noexcept + : d(std::move(other.d)) +{ +} + +/*! Destroys the time zone. */ diff --git a/src/corelib/time/qtimezone.h b/src/corelib/time/qtimezone.h index b43f1f2af2..825caf1740 100644 --- a/src/corelib/time/qtimezone.h +++ b/src/corelib/time/qtimezone.h @@ -62,6 +62,7 @@ public: const QString &abbreviation, QLocale::Territory territory = QLocale::AnyTerritory, const QString &comment = QString()); QTimeZone(const QTimeZone &other); + QTimeZone(QTimeZone &&other) noexcept; ~QTimeZone(); QTimeZone &operator=(const QTimeZone &other); |