find difference between two struct instances.

FoxyBrown via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 21 16:38:51 PDT 2017


On Friday, 21 July 2017 at 22:35:20 UTC, Era Scarecrow wrote:
> 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.
>

No, it isn't. It is a concept, wasn't mean to be taken as literal 
D code.

>  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).

Why do I want to go through all that trouble? A simple binary 
compare should suffice.


More information about the Digitalmars-d-learn mailing list