rgba.ptr[0] vs rgba[0]

visitor pierredavant at gmail.com
Mon Nov 23 17:34:27 UTC 2020


Hi all,

I would like to know why in the code below, rgba.ptr[0] is used 
instead of rgba[0] and allowing the method to be @safe

float[4] rgba = 0;
ref inout(float) r() inout pure @trusted { pragma(inline, true); 
return rgba.ptr[0]; }

why not :
ref inout(float) r() inout pure @safe { pragma(inline, true); 
return rgba[0]; }

avoid an allocation maybe ?

Thanks for your time.


More information about the Digitalmars-d-learn mailing list