On Wednesday, 26 July 2017 at 16:27:57 UTC, WhatMeWorry wrote:
On Wednesday, 26 July 2017 at 02:31:33 UTC, Mike Parker wrote:
With static arrays, the memory for the elements if part of the
array itself, so it is counted in the size. For dynamic
arrays, it is not. For .sizeof to report the size of the
allocated memory would be incorrect.
OK, Then I assume the critical thing is that dynamic arrays
memory is
not part of the array itself. But is this a deal breaker?
A deal breaker for what? For making sizeof return the amount of
memory allocated? Yes. It's the same behavior in C and C++:
float verts[3];
assert(sizeof(verts) == (sizeof(float) * 3));
float *verts = malloc(sizeof(float)*3);
assert(sizeof(verts) == sizeof(void*));