1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-17 15:46:05 +02:00

Pointer subtraction using stride instead of size

This commit is contained in:
Brian Fiete 2023-03-01 05:41:20 -05:00
parent 357f29f94a
commit 200bb6453c
3 changed files with 30 additions and 1 deletions

View file

@ -189,6 +189,20 @@ namespace Tests
StructN sn = GetStructN();
Test.Assert(sn.mA == 123);
List<StructD> list = scope .();
for (int i < 10)
list.Add(default);
var ptr0 = &list[0];
var ptr9 = &list[9];
int count = ptr9 - ptr0;
Test.Assert(count == 9);
var ptr9B = ptr0 + 9;
count = ptr9B - ptr0;
Test.Assert(ptr9 == ptr9B);
Test.Assert(count == 9);
}
[Align(16)]