Do equality checks for dynamic arrays attempt to shortcut with pointer comparison

monarch_dodra monarchdodra at gmail.com
Thu Apr 3 09:31:43 PDT 2014


On Thursday, 3 April 2014 at 16:05:27 UTC, dnspies wrote:
> But I still don't see how this opEquals which takes two Objects 
> could possibly accept dynamic arrays instead.

It doesn't. The link you were given was not relevent.

> Object is a class-type so its instances can only be accessed by 
> reference (which is only a single pointer internally).  Thus 
> the size of the parameters to this function is two pointers.  
> But a dynamic array is a pointer paired with a length (which is 
> the same size as two pointers) meaning the size of the 
> parameters two any function taking two arrays would have to be 
> four pointers.  So it seems like any function which would work 
> on both would have to be templated (but this one isn't).  Are 
> you sure that this is the opEquals that gets used with dynamic 
> arrays and not a different one somewhere else?

It's not the one for dynamic arrays. AFAIK, the one for arrays is 
fully compiler generated, so you won't find it anywhere.


More information about the Digitalmars-d-learn mailing list