On Saturday 11 December 2010 19:16:29 Jonathan M Davis wrote:
> On Saturday 11 December 2010 19:08:33 Simen kjaeraas wrote:
> > Jonathan M Davis <[email protected]> wrote:
> > > This behavior is intended. Arrays are actually something like this
> > > under the hood:
> > >
> > > struct array(T)
> > > {
> > >
> > > T* arr;
> > > size_t length;
> > >
> > > }
> >
> > Actually, that is:
> >
> > struct array(T)
> > {
> >
> > size_t length;
> > T* ptr;
> >
> > }
> >
> > To get the layout and names right.
> > ( http://digitalmars.com/d/2.0/abi.html )
>
> Good point. Though actually, I don't think that that's quite right either,
> because it has capacity as well. It seems like there's an error in the
> documentation.
On further inspection, it looks like capacity is not actually part of the array
struct. It's an external property function which uses garbage collector voodoo
to determine the array's capacity. And it looks like the actual struct looks
like this (in rt.lifetime in druntime):
struct Array2
{
size_t length;
void* ptr;
}
So, it's not even templatized.
- Jonathan M Davis