Immutability and arrays
Steven Schveighoffer
schveiguy at gmail.com
Tue Dec 14 16:21:03 UTC 2021
On 12/14/21 11:19 AM, Steven Schveighoffer wrote:
> Er... scratch that, this isn't construction, it should use opAssign.
> Again, probably because memcpy+postblit is used by the runtime.
>
> If not reported, it should be.
Simple proof that it is a bug:
```d
immutable (ComplexStruct)[] arr;
ComplexStruct[] arr2;
arr2[0] = arr[0]; // ok
arr2[] = arr[]; // error
```
If you can copy one element, you should be able to copy all the elements.
-Steve
More information about the Digitalmars-d-learn
mailing list