けどopEqualsはref const引数を要求してくる.
import std.stdio; struct X { bool opEquals(ref const(X) x) const { return true; } } struct Y { X getX() const { return X(); } } void main() { X x; Y y; writeln(x == y.getX); // Error: y.getX() is not an lvalue }
しょうがないのかなーこれ.
ref const(X) getX() const
にすれば大丈夫なのだが.