Skip to content

Commit

Permalink
Merge pull request #90631 from AThousandShips/array_iter_fix
Browse files Browse the repository at this point in the history
[Core] Fix incorrect comparison for `Array` const iterator
  • Loading branch information
akien-mga authored Apr 13, 2024
2 parents 43b32f9 + 80cb914 commit 578d937
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/variant/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Array {
_FORCE_INLINE_ ConstIterator &operator--();

_FORCE_INLINE_ bool operator==(const ConstIterator &p_other) const { return element_ptr == p_other.element_ptr; }
_FORCE_INLINE_ bool operator!=(const ConstIterator &p_other) const { return element_ptr == p_other.element_ptr; }
_FORCE_INLINE_ bool operator!=(const ConstIterator &p_other) const { return element_ptr != p_other.element_ptr; }

_FORCE_INLINE_ ConstIterator(const Variant *p_element_ptr, Variant *p_read_only = nullptr) :
element_ptr(p_element_ptr), read_only(p_read_only) {}
Expand Down
4 changes: 4 additions & 0 deletions tests/core/variant/test_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -555,13 +555,17 @@ TEST_CASE("[Array] Iteration") {
idx++;
}

CHECK_EQ(idx, a1.size());

idx = 0;

for (const Variant &E : (const Array &)a1) {
CHECK_EQ(int(a2[idx]), int(E));
idx++;
}

CHECK_EQ(idx, a1.size());

a1.clear();
}

Expand Down

0 comments on commit 578d937

Please sign in to comment.