[Issue 8681] dmd accepts mutable AA key types for objects
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Sep 21 09:15:13 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=8681
Marco Leise <Marco.Leise at gmx.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Marco.Leise at gmx.de
--- Comment #2 from Marco Leise <Marco.Leise at gmx.de> ---
(In reply to hsteoh from comment #1)
What works with the type system is to isolate the fields from C that define its
equality:
struct ImmutableCPart
{
int x;
size_t toHash() const {
return typeid(int).getHash(x);
}
bool opEquals(const C c) const {
return x == c.x;
}
}
class C {
immutable ImmutableCPart x;
int y, z;
this() { ... /* initialize x */ }
}
C[ImmutableCPart] lookup;
--
More information about the Digitalmars-d-bugs
mailing list