Comment #0 by stanislav.blinov — 2018-11-22T20:51:55Z
struct S {
int x;
this(this) {
/* do @system stuff... */
import std.stdio;
writeln("copy");
}
const:
bool opEquals(S rhs) { return x == rhs.x; }
size_t toHash() { return hashOf(x); }
}
void testS() @safe nothrow pure {
S a;
auto b = a;
a.opEquals(b);
auto h = a.toHash();
}
void testAA() @safe nothrow pure {
int[S] aa;
S key;
aa[key] = 0;
}
testS() will not compile since neither postblit, nor opEquals or toHash satisfy the attributes.
But testAA() compiles, even though the AA implementation calls all the same functions.
Comment #1 by robert.schadek — 2024-12-13T19:01:27Z