"Overlapping array copy" exception sorting an array of Tuples

Jonathan M Davis jmdavisProg at gmx.com
Mon Mar 7 15:35:08 PST 2011


On Monday, March 07, 2011 10:38:44 André Stein wrote:
> I tried both signatures of opCmp but the result seemed the same (both
> sequences of structs sorted correctly). So I wonder what is the default
> comparison of a user defined struct type? Not implementing an opCmp
> function lead to a compiler error..

It probably either does a comparison of the object's byte representation or 
compares each member variable in turn. I don't know - probably something along 
the lines of the former. I wouldn't recommend relying on it. Regardless, in this 
case, you have the int first, so unless you compare two structs with the same 
value for that first int field, you wouldn't see any difference anyway.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list