Question

As far I know maps in D have value semantics.

If so why does the second line in this example fail

const(uint[ubyte]) x;
uint[ubyte] y = x;

as

Error: cannot implicitly convert expression (x) of type const(uint[ubyte]) to uint[ubyte]

when both the key and value also have value semantics?

Was it helpful?

Solution

As far I know maps in D have value semantics.

D associative arrays are reference types.

Internally, they are represented as a pointer to an implementation-defined data structure. (Note that if the AA is null, it does not act like a reference type, as adding the first member will instantiate it.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top