mirror of
https://github.com/nlohmann/json.git
synced 2026-11-19 05:56:07 +00:00
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:
@@ -108,7 +108,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
|
||||
|
||||
Reference in New Issue
Block a user