On Thursday, 11 June 2015 at 20:09:38 UTC, Adel Mamin wrote:
import std.stdio;
void main()
{
ubyte[] a1 = new ubyte[65];
ubyte[65] a2;
writeln("a1.sizeof = ", a1.sizeof); // prints 16
writeln("a2.sizeof = ", a2.sizeof); // prints 65
}
Why a1.sizeof is 16?
ubyte[] is a slice,
On Thursday, 11 June 2015 at 20:09:38 UTC, Adel Mamin wrote:
Why a1.sizeof is 16?
sizeof is tied to *type*, not a variable. (I kinda wish a1.sizeof
was prohibited, forcing you to say typeof(a1).sizeof so it is
clear but whatever).
A dynamic array's size is the length variable plus the point
import std.stdio;
void main()
{
ubyte[] a1 = new ubyte[65];
ubyte[65] a2;
writeln("a1.sizeof = ", a1.sizeof); // prints 16
writeln("a2.sizeof = ", a2.sizeof); // prints 65
}
Why a1.sizeof is 16?