Fix function overload resolution. Add static array not working.
This commit is contained in:
29
static_array.jai
Normal file
29
static_array.jai
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user