Is "auto t=T();" not the same as "T t;"?
Steven Schveighoffer
schveiguy at gmail.com
Tue Oct 25 18:23:31 UTC 2022
On 10/25/22 2:03 PM, Ali Çehreli wrote:
> On 10/25/22 11:01, Ali Çehreli wrote:
>
> > static arrays don't have .ptr to point
> > to any member.
>
> Why do I say incorrect things like that? :) Of course static arrays have
> .ptr as well but that always point to their own body of N elements. They
> own their elements... I move away from the keyboard now... :)
You were right actually. The `arr.ptr` is a shortcut for the address of
the first element.
A dynamic array is equivalent to a struct with a `ptr` and `length`
fields. A static array does not have fields, it's just the data itself.
The properties are not real fields, but lowerings so they can be used
like dynamic arrays.
-Steve
More information about the Digitalmars-d-learn
mailing list