2023-11-17 12:51:26 -04:00
|
|
|
#pragma once
|
2023-11-17 14:14:55 -04:00
|
|
|
/*
|
|
|
|
* Need to pass in the size of the array, since pointer arrays don't know their size
|
|
|
|
* Can use sizeof(array) / sizeof(type) to get the size of the array if it is not a pointer
|
|
|
|
* Decays everything into pointers, as you cannot assign two different types in a for loop declaration
|
|
|
|
* For example, cannot do int* iter, int item = *iter, as they are different types
|
|
|
|
* You need to dereference the item, as it is a pointer to the current element
|
|
|
|
*/
|
|
|
|
#define foreach(type, item, array, size) \
|
2023-11-17 12:51:26 -04:00
|
|
|
for (type* item = array; item < array + size; item++)
|