summaryrefslogtreecommitdiff
path: root/src/corelib/tools/qvarlengtharray.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2021-12-10 22:47:24 +0100
committerMarc Mutz <marc.mutz@qt.io>2021-12-11 16:57:08 +0100
commit7670db3146c402ddb322887976a6edf639ed9a71 (patch)
tree08e2d969eea906cbf46ab4a0f8648e6f7bda8afe /src/corelib/tools/qvarlengtharray.h
parentd3d284bec423d936e936cdb756b6e1bd2ad537b8 (diff)
downloadqtbase-7670db3146c402ddb322887976a6edf639ed9a71.tar.gz
QVLA: separate control from inline storage [11/11]: qHash()
A previous attempt to make qHash() a hidden friend ran into an ICE on Clang, so to simplify the implementation, QVLABase::hash() is public for now. Use QtPrivate::QNothrowHashable_v to simplify the noexcept clauses. Fixes: QTBUG-84785 Change-Id: Ibb520bde7b1d6dc45846bd8e1fa27c39c401b96a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/tools/qvarlengtharray.h')
-rw-r--r--src/corelib/tools/qvarlengtharray.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index e6ff615b03..07add066af 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -193,6 +193,10 @@ public:
iterator erase(const_iterator begin, const_iterator end);
iterator erase(const_iterator pos) { return erase(pos, pos + 1); }
+ size_t hash(size_t seed) const noexcept(QtPrivate::QNothrowHashable_v<T>)
+ {
+ return qHashRange(begin(), end(), seed);
+ }
protected:
template <typename...Args>
reference emplace_back_impl(qsizetype prealloc, void *array, Args&&...args)
@@ -926,9 +930,9 @@ bool operator>=(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T,
template <typename T, qsizetype Prealloc>
size_t qHash(const QVarLengthArray<T, Prealloc> &key, size_t seed = 0)
- noexcept(noexcept(qHashRange(key.cbegin(), key.cend(), seed)))
+ noexcept(QtPrivate::QNothrowHashable_v<T>)
{
- return qHashRange(key.cbegin(), key.cend(), seed);
+ return key.hash(seed);
}
template <typename T, qsizetype Prealloc, typename AT>