On 6/19/15 2:28 AM, Timon Gehr wrote:
That's not the issue. The data held by the structure shouldn't be mutated, since it is persistent. Returning const(T) means that the data that the return value refers to may not be mutated. This is crippling.
I don't understand. So what should be done here?
BTW: sharing of structure between instances is the main motivation for persistent data structures. opAssign shouldn't move. (opAssign should never move, assignment is not the same as a move.)
This is a confusion - opAssign doesn't really move. (It moves from an rvalue.) Try it out - it does what one would expect it to do.
Andrei
