opEquals optimized away?
anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon May 4 22:26:16 PDT 2015
On Tuesday, 5 May 2015 at 04:09:03 UTC, Manfred Nowak wrote:
> class C{
> override bool opEquals( Object o){
> return true;
> }
> }
> unittest{
> auto c= new C;
> assert( c == c);
> }
>
> `rdmd --main -unittest -cov' shows, that opEquals is not
> executed. Why?
>
> -manfred
because `c is c`
https://github.com/D-Programming-Language/druntime/blob/0ac255d7276b9b825eb6f1e677e9ee4f5ad49ca2/src/object.di#L61
More information about the Digitalmars-d-learn
mailing list