Syntax Sugar for Initializing a Fixed float Array as void*?

Adam D Ruppe destructionator at gmail.com
Thu Dec 1 00:47:18 UTC 2022


On Thursday, 1 December 2022 at 00:39:21 UTC, jwatson-CO-edu 
wrote:
> Is there a way to write a single statement that creates a void 
> pointer that points to an initialized float array?

         void* f = [1.0f, 1.0f, 1.0f].ptr;

Though I'd recommend keeping it typed as float[] until the last 
possible moment. If you are passing it a function, remmeber 
pointers convert to void* automatically, so you can do like:

float[] f = [1,1,1];

some_function_taking_void(f.ptr);

and it just works.


More information about the Digitalmars-d-learn mailing list