Fix reverse iterator subscript exception for objects (#6125)

* Fix reverse iterator subscript exception for objects

Signed-off-by: Anshika Grover <anshikag.151107@gmail.com>

* Add reverse iterator subscript tests and comment

Signed-off-by: Anshika Grover <anshikag.151107@gmail.com>

* Add primitive reverse iterator subscript tests

Signed-off-by: Anshika Grover <anshikag.151107@gmail.com>

---------

Signed-off-by: Anshika Grover <anshikag.151107@gmail.com>
This commit is contained in:
Anshika Grover authored and GitHub committed 2026-11-18 22:43:28 +01:00
1 parent d732d616ba
commit 555ef48fb6
3 files changed
+17 -6

No files matched your search

+3 -1
View File
@@ -26795,7 +26795,9 @@ class json_reverse_iterator : public std::reverse_iterator<Base>
/// access to successor
reference operator[](difference_type n) const
{
return *(this->operator+(n));
// the element n positions after *this is the one n + 1 positions before base();
// Base::operator[] then reports invalid_iterator.208 for object iterators
return this->base()[-n - 1];
}
/// return the key of an object iterator