April 24, 2005 opAssign: a suggestion | ||||
---|---|---|---|---|
| ||||
How about allowing overloading of opAssign as long as the type of the right hand side is not the same as the type of the left hand side. In this way a normal assignment will still always just copy the reference as is the case at the moment. This will help a lot when writing container classes. Example: class A { B data; void opAssign(A a) { // ERROR: rhs same type as lhs .. } void opAssign(B b) P // OK! data = b; } .. } Jacques |
Copyright © 1999-2021 by the D Language Foundation