Skip to content

Commit d0bdd60

Browse files
Optionaly add compatibility operators
1 parent 12a1283 commit d0bdd60

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

include/godot_cpp/templates/list.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,11 @@ class List {
523523
}
524524
}
525525

526+
// Index operator, kept for compatibility.
527+
_FORCE_INLINE_ T &operator[](int p_index) {
528+
return get(p_index);
529+
}
530+
526531
// Random access to elements, use with care,
527532
// do not use for iteration.
528533
T &get(int p_index) {
@@ -538,6 +543,11 @@ class List {
538543
return I->get();
539544
}
540545

546+
// Index operator, kept for compatibility.
547+
_FORCE_INLINE_ const T &operator[](int p_index) const {
548+
return get(p_index);
549+
}
550+
541551
// Random access to elements, use with care,
542552
// do not use for iteration.
543553
const T &get(int p_index) const {

0 commit comments

Comments
 (0)