Fix function overload resolution. Add static array not working.

This commit is contained in:
2024-06-25 08:54:02 +02:00
parent d2614b3ba9
commit 3bbbc1d556
6 changed files with 161 additions and 89 deletions

29
static_array.jai Normal file
View File

@@ -0,0 +1,29 @@
Static_Array :: struct ($T : Type, $N : s64) {
array : [N] T;
capacity : s64 = N;
count : s64;
}
// operator [] :: (array : Static_Array($T, $N), index : int) -> T {
// assert(index < array.count);
// return array.array[index];
// }
// operator []= :: (array : *Static_Array($T, $N), index : int, value : T) {
// assert(index < array.count);
// array.array[index] = value;
// }
operator *[] :: (array : *Static_Array($T, $N), index : int) -> *T {
assert(index < array.count);
return *(array.array[index]);
}
array_add :: (array : *Static_Array($T, $N), item : T) {
assert(array.count + 1 < array.capacity);
print("%\n", array[array.count]);
array[array.count] = item;
array.count += 1;
}