import std.stdio; void main() { int[] a = [1,2,3,4,5,6,7,8,9,10]; write(a.sizeof); }
In the following code, the sizeof of a static array is 8 bytes. I am using x86 Windows 8, so the pointer is 4 bytes. Why am I getting an 8-byte array size?
Because it int[]is a dynamic array, not a pointer. Arrays in D are not pointers. What they are is essentially
int[]
struct(T) { T* ptr; size_t length; }
, , ptr, C/++ ( C/++ ). , length D , C/++. D, . , D.
ptr
length
, sizeof ptr length , 8 32- 16 64- .
sizeof
8
16
(, ) - , size_t, 4 .
size_t
D , ( ) O(1).
O(1)
Source: https://habr.com/ru/post/1546584/More articles:Add box-shadow field to column (top to bottom)? - javascriptPostgreSQL's subsequent behavior after receiving "Terminate" ("X") after "COMMIT" - erlangQPX Express API: why is Ryanair missing? - google-apiHow to specify which layout to use for Android Wearable? - androidError message java.io.FileNotFoundException - javaInjection parameter to automatically configure ValueResolver Automapper using Ninject - asp.net-mvc-5Unix permission installation speed - securityUnable to rotate: after pseudo-element using CSS in IE8 - cssHow to add a button directly to Notification on Android Wear - androidTesting csrf token in django - pythonAll Articles