Jonathan M Davis <> changed:

           What    |Removed                     |Added
                 CC|                            |

--- Comment #1 from Jonathan M Davis <> 2012-04-05 18:22:49 
PDT ---
Actually, I don't believe that this is a bug. With this release, Foo() has been
fixed so that it's not an lvalue. Previously Foo() would have been considered
an lvalue but a Foo returned from a function would not making it so that

assert(foo == Foo());

worked by

assert(foo == getFoo());

did not. Many of us considered it incredibly inconsistent to treat struct
literals as lvalues. They're temporaries and don't represent variables or
places in memory at all. So, they shouldn't be lvalues. And not they're not, so
your opEquals doesn't work.

Given that auto ref currently only works with templates, I believe that the
correct solution for this is to then declare 2 overloads of opEquals.

struct Foo
    bool opEquals(ref const Foo b) const
        return true;

    bool opEquals(Foo b) const
        return true;

One will work with lvalues and avoid copying them, whereas the other will work
with rvalues. I believe that when Kenji fixed it so that struct literals aren't
lvalues, he also went into Phobos and fixed it so that all structs which define
opEquals define both overloads of opEquals. You'll need to do the same.

So yes, this change breaks code, but as I understand it, it's a bug fix, not a

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to