Should (p - q) be disallowed in @safe code?

Walter Bright newshound2 at digitalmars.com
Thu Jan 1 17:20:33 UTC 2026


On 1/1/2026 7:16 AM, claptrap wrote:
> I use this all the time to iterate multiple arrays in lockstep.
> 
> size_t offset = q-p;
> 
> you access q with "p[offset]", and you just iterate p
> 
> I tried to avoid using it but it is just faster sometimes,

@safe code doesn't allow pointer arithmetic, and so such code would have to be 
marked @trusted anyway.


More information about the Digitalmars-d mailing list