find difference between two struct instances.

Era Scarecrow via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 21 15:35:20 PDT 2017


On Friday, 21 July 2017 at 21:03:22 UTC, FoxyBrown wrote:
> Is there a way to easily find the differences between to struct 
> instances? I would like to report only the differences
>
> e.g.,
>
> writeln(s1 - s2);
>
> prints only what is different between s1 and s2.

  This is entirely dependent on the structs in question, you can't 
just subtract any struct from another struct unless it knows how 
to do it.

  Depends on what the structures hold. You'll probably have to 
either make an opSub, a function to call opBinary!"-", or do 
opCmp which returns which is higher/lower (and may be as simple 
as subtraction).




More information about the Digitalmars-d-learn mailing list