safe method overloading with different refness of its arguments
drug via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jul 4 03:40:42 PDT 2017
```
struct Foo
{
ubyte width, length;
// by reference
bool opEquals(ref const(Foo) other) const pure @safe
{
if (width != other.width)
return false;
if (length != other.length)
return false;
return true;
}
// by value
bool opEquals(const(Foo) other) const pure @safe
{
return opEquals(other);
}
}
```
It works for me, but I'm curious - will compiler always recognize what
to call and I can avoid recursion and stack overflow or I shouldn't do so?
More information about the Digitalmars-d-learn
mailing list