diff --git a/src/corelib/kernel/qjniarray.h b/src/corelib/kernel/qjniarray.h index bf09e9db63a..748830a04ea 100644 --- a/src/corelib/kernel/qjniarray.h +++ b/src/corelib/kernel/qjniarray.h @@ -50,6 +50,12 @@ struct QJniArrayIterator ++that.m_index; return that; } + friend QJniArrayIterator operator++(QJniArrayIterator &that, int) noexcept + { + auto copy = that; + ++that; + return copy; + } void swap(QJniArrayIterator &other) noexcept { diff --git a/tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp b/tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp index 6e05dd27a83..65dd832e92e 100644 --- a/tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp +++ b/tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp @@ -92,6 +92,17 @@ void tst_QJniArray::operators() QJniArray array(bytes); QVERIFY(array.isValid()); + { + auto it = array.begin(); + QCOMPARE(*it, 'a'); + QCOMPARE(*++it, 'b'); + QCOMPARE(*it++, 'b'); + QCOMPARE(*it, 'c'); + ++it; + it++; + QCOMPARE(*it, 'e'); + QCOMPARE(++it, array.end()); + } { QJniArray::const_iterator it = {}; QCOMPARE(it, QJniArray::const_iterator{});