opIs broke for structs?

bearophile bearophileHUGS at lycos.com
Sat Oct 13 15:42:33 PDT 2012


Era Scarecrow:

>  I'm curious why this would break and not work, as is should 
> compare against it's location/entity correct? I wonder why it 
> breaks then for structs on the stack. I can only find 'opIs 
> missing' when searching for it, so...

"is" is meant to perform a bitwise comparison (I think today it 
is working as designed or it's very close to this target).

So on class references "is" performs a bitwise comparison of the 
references themselves.

On values (like structs) "is" compares the struct values bit-wise.

In your code x1 and x2 contain the same bit patterns (32 bits set 
to zero), so "x1 is x2" is true.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list