test49

Undocumented in source.
immutable
auto test49 = q{--- test49 // Test full suite of pointer arithmetic operations void preIncrement(i32* arr, i32 length) { (++arr)[-1] = 10; // arr[0] = 10, negative index *arr = 15; // arr[1] = 15, deref pointer } void preDecrement(i32* arr, i32 length) { (--arr)[1] = 20; // arr[0] = 20 arr[2] = 25; // arr[1] = 25 } void postIncrement(i32* arr, i32 length) { (arr++)[0] = 30; // arr[0] = 30 arr[0] = 35; // arr[1] = 35 } void postDecrement(i32* arr, i32 length) { (arr--)[0] = 40; // arr[0] = 40 arr[2] = 45; // arr[1] = 45 } void addInt(i32* arr, i32 length) { *(arr + 3) = 50; // arr[3] = 50 } void subInt(i32* arr, i32 length) { *(arr - 3) = 60; // arr[-4] = 60 } void diff(i32* arr, i32 length) { i32* last = arr + length; // last = &arr[4]; // sub two pointers i64 diff = last - arr; arr[length - 3] = cast(i32)diff; // ar[1] = 4 } void plusEqual(i32* arr, i32 length) { arr += 3; arr[0] = 90; // arr[3] = 90 } void minusEqual(i32* arr, i32 length) { arr -= 3; arr[3] = 100; // arr[0] = 100 } };

Meta