Re: Array of const objects with indirections and std.algorithm.copy

2016-07-28 Thread drug007 via Digitalmars-d-learn
On 28.07.2016 21:45, Ali Çehreli wrote: On 07/27/2016 04:51 AM, drug wrote: > cfoo.copy(foo); // fails to compile because phobos in case of array uses > // array specialization and this specialization fails > // see > https://github.com/dlang/phobos/blob/v2.07

Re: Array of const objects with indirections and std.algorithm.copy

2016-07-28 Thread Ali Çehreli via Digitalmars-d-learn
On 07/27/2016 04:51 AM, drug wrote: > cfoo.copy(foo); // fails to compile because phobos in case of array uses > // array specialization and this specialization fails > // see > https://github.com/dlang/phobos/blob/v2.071.1/std/algorithm/mutation.d#L333 Thanks f

Re: Array of const objects with indirections and std.algorithm.copy

2016-07-28 Thread drug via Digitalmars-d-learn
I see. I'll try to rephrase my question to be clear. We have: ``` struct Foo { int i; float f; } int main() { const(Foo)[] cfoo = [Foo(1, 0.5), Foo(2, 0.75)]; Foo[] foo; cfoo.copy(foo); // it works, constness no matter here because Foo is value type } ``` but i

Re: Array of const objects with indirections and std.algorithm.copy

2016-07-27 Thread Ali Çehreli via Digitalmars-d-learn
On 07/27/2016 04:51 AM, drug wrote: > I have the following: > > ``` > struct Foo > { > int[] i; > > this(int[] i) > { > this.i = i.dup; > } > > ref Foo opAssign(ref const(this) other) > { > i = other.i.dup; > > return this; > } > } You're defini