Re: About Immutable struct members and arrays.

2016-01-07 Thread Jack Applegame via Digitalmars-d-learn
On Thursday, 7 January 2016 at 00:19:12 UTC, anonymous wrote: On 06.01.2016 23:04, Jack Applegame wrote: move(bar, arr[0]); // ok I consider it a bug that this compiles. You're overwriting immutable data, which shouldn't be possible (without casting).

Re: About Immutable struct members and arrays.

2016-01-06 Thread anonymous via Digitalmars-d-learn
On 06.01.2016 23:04, Jack Applegame wrote: import std.algorithm; struct Bar { const int a; int b; } void main() { Bar[1] arr; Bar bar = Bar(1, 2); bar[0].b = 4; Assuming you meant `arr[0].b = 4;`. Just overwriting the mutable part of bar[0] is ok, of course.

About Immutable struct members and arrays.

2016-01-06 Thread Jack Applegame via Digitalmars-d-learn
import std.algorithm; struct Bar { const int a; int b; } void main() { Bar[1] arr; Bar bar = Bar(1, 2); bar[0].b = 4; move(bar, arr[0]); // ok arr[1] = bar;// fail, why? move(Bar(1, 2), arr[0]); // fail, why source parameter isn't auto ref? }