문제

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?

도움이 되었습니까?

해결책

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.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top