recursive equal, and firstDifference functions

Jonathan M Davis jmdavisProg at gmx.com
Tue Mar 19 19:03:16 PDT 2013


On Tuesday, March 19, 2013 18:20:35 H. S. Teoh wrote:
> I like this idea. By default, provide something that recursively
> compares struct/class members, array elements, etc.. But if at any level
> an opEquals is defined, then that is used instead. This maximizes
> convenience for those cases where you *do* just want a literal equality
> of all sub-structures, but also allows you to override that behaviour if
> your class/struct needs some other special processing.

We already get this. That's what == does by default. It's just that it uses == 
on each member, so if == doesn't work for a particular member variable and the 
semantics you want for == on the type it's in, you need to override opEquals.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list