summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2022-09-10 19:40:51 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-09-12 18:47:23 +0000
commit358248b4950131711ae408da9aa30d41c5143e4f (patch)
tree02c19a20d30b85d09ba622fa2f2c5254fcac89c4 /src/corelib/tools
parent553185e8c3a71d74be368745c3c6a3d5bcffe7e1 (diff)
Make QCryptographicHash move constructible
This adds a move constructor, a move assignment operator and a swap function to QCryptographicHash. This can (to name one example) be useful when you want to store multiple hashes in a vector. [ChangeLog][QtCore][QCryptographicHash] Added move constructor, move assignment operator and swap() function. Change-Id: Id54594fa69104ec25ad78581f962a021e85531c2 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qcryptographichash.cpp33
-rw-r--r--src/corelib/tools/qcryptographichash.h4
2 files changed, 37 insertions, 0 deletions
diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp
index 8d60be175e..3f6075f2aa 100644
--- a/src/corelib/tools/qcryptographichash.cpp
+++ b/src/corelib/tools/qcryptographichash.cpp
@@ -316,6 +316,18 @@ QCryptographicHash::QCryptographicHash(Algorithm method)
}
/*!
+ \fn QCryptographicHash::QCryptographicHash(QCryptographicHash &&other)
+
+ Move-constructs a new QCryptographicHash from \a other.
+
+ \note The moved-from object \a other is placed in a
+ partially-formed state, in which the only valid operations are
+ destruction and assignment of a new value.
+
+ \since 6.5
+*/
+
+/*!
Destroys the object.
*/
QCryptographicHash::~QCryptographicHash()
@@ -324,6 +336,27 @@ QCryptographicHash::~QCryptographicHash()
}
/*!
+ \fn QCryptographicHash &QCryptographicHash::operator=(QCryptographicHash &&other)
+
+ Move-assigns \a other to this QCryptographicHash instance.
+
+ \note The moved-from object \a other is placed in a
+ partially-formed state, in which the only valid operations are
+ destruction and assignment of a new value.
+
+ \since 6.5
+*/
+
+/*!
+ \fn void QCryptographicHash::swap(QCryptographicHash &other)
+
+ Swaps cryptographic hash \a other with this cryptographic hash. This
+ operation is very fast and never fails.
+
+ \since 6.5
+*/
+
+/*!
Resets the object.
*/
void QCryptographicHash::reset() noexcept
diff --git a/src/corelib/tools/qcryptographichash.h b/src/corelib/tools/qcryptographichash.h
index f5710015cf..94fc82783b 100644
--- a/src/corelib/tools/qcryptographichash.h
+++ b/src/corelib/tools/qcryptographichash.h
@@ -64,8 +64,12 @@ public:
Q_ENUM(Algorithm)
explicit QCryptographicHash(Algorithm method);
+ QCryptographicHash(QCryptographicHash &&other) noexcept : d(std::exchange(other.d, nullptr)) {}
~QCryptographicHash();
+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QCryptographicHash)
+ void swap(QCryptographicHash &other) noexcept { qt_ptr_swap(d, other.d); }
+
void reset() noexcept;
#if QT_DEPRECATED_SINCE(6, 4)