godotengine / godotengine/godot-cpp
Iterators over Array, Pool*Array, etc.
- Dominant language
- C++
- Stars
- 2.7k
- Forks
- 809
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 8
Description
In GDScript you can do the following to iterate over an array:
```
things = [1,2,3,4,5]
for x in things:
# do something with x
pass
```
C++11 added support for for-each loops that look like
```
for (Thing& x : container)
; // do thing with x
```
but it requires the class of container to define the members begin() and end(), which return iterators to the first element and to after the last element of the container.
I think iterators types should be defined for Array and Pool*Array, as well as begin and end members. The one for array could be represented with a pointer to the Array and an index, while the ones for the pool arrays could just be a pointer (like how std::vector is typically implemented).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.