struct opEquals does not work with parameter of same type - bug or feature?
Sean Eskapp
eatingstaples at gmail.com
Mon Aug 29 15:41:26 PDT 2011
I am trying to build a struct with equality testing, using this code:
struct Foo
{
const bool opEquals(Foo f)
{
return true;
}
}
This gives me the error that the parameter should be of type "ref const Foo".
Fine.
struct Foo
{
const bool opEquals(ref const Foo f)
{
return true;
}
}
This, however, does not work with code like:
Foo bar()
{
return Foo();
}
assert(Foo() == bar());
"function Foo.opEquals(ref const const(Foo) f) const is not callable using
argument types (Foo)" and "bar() is not an lvalue".
How can I do this?
More information about the Digitalmars-d-learn
mailing list