casting issue
Dicebot
public at dicebot.lv
Thu Oct 24 11:21:58 PDT 2013
On Thursday, 24 October 2013 at 17:59:03 UTC, Alexandr Druzhinin
wrote:
> May I cast like:
>
> struct Point
> {
> float x, y, z;
> float r, g, b, a;
> }
>
> Point[] points;
>
> void foo(float[] float_array) {};
>
> foo(cast(float[]) points); // is it safe?
>
> May be more elegant way do express this exists?
>
> Thanks
Not entirely. Try adding `align(64)` to struct declaration and
observe funny change ;) It is clearly some low-level hack and not
something for usage in normal code.
One can create array from struct instance via [ point.tupleof ],
but this will allocate as all array literals do.
More information about the Digitalmars-d-learn
mailing list