QJniArray: use comparison macros

Implement comparesEqual, declare the type as QUALITY_COMPARABLE.

Task-number: QTBUG-126150
Change-Id: I5a2371a850525dbf2e29fefa1a6cf85bb9b59cff
Reviewed-by: Soheil Armin <soheil.armin@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit b5ec0f7a4663f201167e856e5534d7fee5314e8b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Volker Hilsheimer 2024-06-24 10:27:47 +02:00 committed by Qt Cherry-pick Bot
parent 4378364a50
commit bf97701fd8

View File

@ -39,14 +39,6 @@ struct QJniArrayIterator
using const_reference = reference;
using iterator_category = std::bidirectional_iterator_tag;
friend bool operator==(const QJniArrayIterator &lhs, const QJniArrayIterator &rhs) noexcept
{
return lhs.m_array == rhs.m_array && lhs.m_index == rhs.m_index;
}
friend bool operator!=(const QJniArrayIterator &lhs, const QJniArrayIterator &rhs) noexcept
{
return !(lhs == rhs);
}
const_reference operator*() const
{
return m_array->at(m_index);
@ -80,6 +72,14 @@ struct QJniArrayIterator
}
private:
friend constexpr bool comparesEqual(const QJniArrayIterator &lhs,
const QJniArrayIterator &rhs)
{
Q_ASSERT(lhs.m_array == rhs.m_array);
return lhs.m_index == rhs.m_index;
}
Q_DECLARE_EQUALITY_COMPARABLE(QJniArrayIterator)
using VT = std::remove_const_t<T>;
friend class QJniArray<VT>;