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


[email protected] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]


--- Comment #1 from [email protected] 2013-07-08 15:09:40 PDT ---
This is not really a bug. Structs by default are bitwise-compared.

If you want structs to be deep-compared, you need to define toHash and opCmp:

struct S {
    char[] str;

    size_t toHash() const {
        // Just use arrays' builtin hash function, no need to reinvent your own
        return typeid(str).getHash(&str);
    }

    // Note: this exact function signature must be used;
    // DMD is currently very picky about this.
    int opCmp(ref const S s) const {
        return typeid(str).compare(&str, &s.str);
    }
}

Once these two pieces are in place, your struct should work correctly as AA
key.

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

Reply via email to