December 20, 2012 struct opAssign in spec | ||||
---|---|---|---|---|
| ||||
Looking at the Kindle spec there appears to be an error in the section for structs called Assignment Overload. S* opAssign (ref const S s) { a = s.a; } gives an error: Error: cannot implicitly convert expression (this) of type S to S* S opAssign (ref const S s) { does compile. |
December 20, 2012 Re: struct opAssign in spec | ||||
---|---|---|---|---|
| ||||
Posted in reply to Red | On 12/19/2012 09:57 PM, Red wrote: > Looking at the Kindle spec Here as well: http://dlang.org/struct.html#AssignOverload > there appears to be an error in the section > for structs called Assignment Overload. > > S* opAssign (ref const S s) { > a = s.a; Of course, there is also the return statement: return this; > } > > gives an error: > Error: cannot implicitly convert expression (this) of type S to S* > > S opAssign (ref const S s) { > > does compile. You are right. The documentation is wrong. Ali |
Copyright © 1999-2021 by the D Language Foundation