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

2017-07-26 Thread Mike Parker via Digitalmars-d-learn
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

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

2017-07-26 Thread WhatMeWorry via Digitalmars-d-learn
On Wednesday, 26 July 2017 at 02:32:07 UTC, Adam D. Ruppe wrote: 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 :) You could also do (cast(ubyte[]) array).length. This was my (way over complicated) att

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

2017-07-26 Thread WhatMeWorry via Digitalmars-d-learn
On Wednesday, 26 July 2017 at 02:31:33 UTC, Mike Parker wrote: On Wednesday, 26 July 2017 at 02:24:06 UTC, WhatMeForget wrote: [...] Because .sizeof has nothing to do with how many elements are in the array. It tells you how much space the array itself takes up. Totally agree. .length ret

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

2017-07-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 26 July 2017 at 02:24:06 UTC, WhatMeForget wrote: 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-

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

2017-07-25 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 26 July 2017 at 02:24:06 UTC, WhatMeForget wrote: 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-

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

2017-07-25 Thread WhatMeForget via Digitalmars-d-learn
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