Kinds of containers
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Wed Oct 21 08:13:36 PDT 2015
On 10/21/2015 05:08 PM, Timon Gehr wrote:
> There would be no mutable aliasing.
Here, I mean within the data structure itself. There is nothing wrong with:
class Cell{ int x=0; }
FunSet!Cell a;
a.insert(new Cell());
auto b=a;
foreach(c;a) c.x=1;
assert(b.x==1);
This is analogous to:
struct SingletonFunSet(T){
T element;
}
auto a=SingletonFunSet!Cell(new Cell());
auto b=a;
a.element.x=1;
assert(b.x==1);
Here, SingletonFunSet!Cell is a value type, but it's constituents might
not be.
More information about the Digitalmars-d
mailing list