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>
bb10
Marc Mutz 2021-12-10 22:47:24 +01:00
parent d3d284bec4
commit 7670db3146
1 changed files with 6 additions and 2 deletions

View File

@ -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>