On Mon, Jul 21, 2014 at 04:42:34PM +0000, bearophile via Digitalmars-d wrote: > Jacob Carlborg: > > >If the struct already has opCmp I need to defined opEquals and toHash? > > From what I know, the new hash protocol requires toHash and opEquals. I > think that now opCmp is not used by hashing.
Yes, finally that has been fixed. > I don't know if you define just toHash and opCmp it uses opCmp as > fallback. [...] I'm inclined to say, file a regression bug. If opCmp is defined but opEquals isn't, the compiler should auto-generate opEquals (as opCmp(...)==0). Requiring the user to implement a separate opEquals when opCmp is already there is nonsensical, and opens the door to stupid bugs due to increased boilerplate. (Of course, if the user also defines opEquals manually, that's fine. But if he doesn't, the compiler should do the Right Thing(tm).) In any case, if either opCmp or opEquals (or both) is defined, then toHash must be defined, since obviously the user doesn't want the default POD comparison implementation, and toHash must always be consistent with opCmp/opEquals otherwise the AA will break. T -- "640K ought to be enough" -- Bill G., 1984. "The Internet is not a primary goal for PC usage" -- Bill G., 1995. "Linux has no impact on Microsoft's strategy" -- Bill G., 1999.
