std.experimental.collection.functional.slist

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 19 06:21:38 PDT 2015


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



More information about the Digitalmars-d mailing list