Convert some ints into a byte array without allocations?

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jan 16 07:42:39 PST 2016


Yazan D:

On Saturday, 16 January 2016 at 14:42:27 UTC, Yazan D wrote:
> ubyte[] b = (cast(ubyte*) &a)[0 .. int.sizeof];

Better to use the actual size:

ubyte[] b = (cast(ubyte*) &a)[0 .. a.sizeof];

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list