dmd 2.065.0
Steven Schveighoffer
schveiguy at yahoo.com
Tue Feb 25 13:51:02 PST 2014
On Tue, 25 Feb 2014 15:12:41 -0500, Jacob Carlborg <doob at me.com> wrote:
>
> The thing is that the compiler complains about a deceleration looking
> like this:
>
> struct TagIndex
> {
> uint tag, index;
> }
If the compiler generates opEquals and opCmp, then it's guaranteed
opEquals(x, y) is equivalent to opCmp(x, y) == 0.
The compiler should NOT complain about this, which I should have more
clearly stated (I thought I had).
> Neither opEquals or opCmp is overloaded. A simple test case will also
> show that the compiler doesn't not complain about a missing opCmp. I
> have not been able to create a reduced test case for this.
I realized, after trying to get opCmp to work, I was missing a piece --
toHash! I couldn't get the thing to only store one key!
So I have to update my requirements. Here are the two cases where a struct
T should be usable as an AA key:
1. Neither opCmp nor opEquals are defined (and defaults are generated).
2. Both opEquals and toHash are defined.
Any other key types should be disallowed.
-Steve
More information about the Digitalmars-d-announce
mailing list