As of http://digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=150299 If we disable this(this) in a struct, the opAssign member function should be used if it exists. Here is a sample code : module fail2; struct Fail { @disable this(this); ref Fail opAssign(ref const Fail t) { return this; } } int main(string[] argv) { Fail a; Fail b = a; // Error: struct fail2.Fail is not copyable because it is annotated with @disable return 0; }
OpAssign never work when a variable is initialized. In this line: > Fail b = a; 'b' is yet not born, but opAssign needs a living 'this' instance. Therefore, the variable 'b' initialization with an lvalue 'a' always tries to copy 'a', then rejected by @disable this(this).