opEquals(const ref yadaYada)
dsimcha
dsimcha at yahoo.com
Sat Dec 12 07:14:50 PST 2009
I've noticed that, for DMD 2.037, we've started mandating that the input
parameter for struct opEquals be const ref T. This seemed like a good idea
initially, but it creates the horribly leaky abstraction that the right-hand
argument to opEquals can't be an rvalue. Example:
struct Foo {
bool opEquals(const ref Foo rhs) const { // Only signature
// that compiles.
return true;
}
}
Foo getFoo() {
return Foo();
}
void main() {
Foo foo = getFoo();
bool isEqual = foo == getFoo();
}
Error: Foo.opEquals type signature should be const bool(ref const(Foo)) not
const bool(Foo rhs)
Will this be getting fixed witht he new operator overloading?
More information about the Digitalmars-d
mailing list