I feel the dynamic array .sizeof property is kind of a bait and switch

WhatMeForget via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 25 19:24:06 PDT 2017


Static Arrays have property
.sizeof which returns the array length multiplied by the number 
of bytes per array element.

Dynamic Arrays have property
.sizeof which returns the size of the dynamic array reference, 
which is 8 in 32-bit builds and 16 on 64-bit builds.

Why not have dynamic arrays with a .sizeof identical to static 
arrays and say another property called .sizeref which handles the 
32 or 64 bit references.

Maybe Phobos has something that I'm not aware of?

I've hand rolled a function which is working for me currently, 
but with my coding ability, I'd feel much safer with something 
official :)

It just seems like something this basic regarding dynamic arrays 
should just be built-in.














More information about the Digitalmars-d-learn mailing list