[Issue 9218] [2.061] Correct signature of struct opCmp no longer accepts enum structs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 29 09:13:30 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=9218



--- Comment #9 from siegelords_abode at yahoo.com 2012-12-29 09:13:28 PST ---
Ok, that workabout is not quite complete (perhaps this is a different bug
now?). While it solves the code in the original comment, this code doesn't
work:

struct A
{
    enum A zero = {}; // Note the difference here

    int opCmp(const ref A a) const
    {
        return 1;
    }

    int opCmp(const A a) const
    {
        return opCmp(a);
    }
}

void main()
{
    A a;
    auto b = a >= A.zero; //The error is now here! test.d(21): Error: A() is
not an lvalue
    auto c = a > a;
    assert(typeid(a).xopCmp !is null);
    typeid(a).xopCmp(&a, &a);
}

Why would enum A zero = A(); work but enum A zero = {}; not work? Is it safe
(in terms of inadvertent GC usage) to use A() instead of {}?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list