opEquals unsafe? Please tell me this isnt true...
Eric via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Nov 24 14:12:08 PST 2014
@safe
class Y { }
@safe
class X { }
@safe
class Z
{
int x;
this()
{
if (typeid(X) == typeid(Y)) x = 1; // Compile Error
else x = 2;
}
}
void main() { new Z; }
// test.d(19): Error: safe function 'test.Z.this'
// cannot call system function 'object.opEquals'
Isn't this analagous to saying that the "instanceof" operator
in java endangers the GC?
Is it correct to replace '==' with 'is'?
-Eric
More information about the Digitalmars-d-learn
mailing list