Re: Use dup on Containers with const Elements

2016-07-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/30/16 5:21 PM, Q. Schroll wrote: On Friday, 29 July 2016 at 19:24:59 UTC, Steven Schveighoffer wrote: On 7/29/16 3:00 PM, Q. Schroll wrote: Cases to consider: Arrays and AAs with const(T) Elements, where T is a value or a reference type respectively. [snip] Questions: (1) Why do I have

Re: Use dup on Containers with const Elements

2016-07-30 Thread Q. Schroll via Digitalmars-d-learn
On Friday, 29 July 2016 at 19:24:59 UTC, Steven Schveighoffer wrote: On 7/29/16 3:00 PM, Q. Schroll wrote: Cases to consider: Arrays and AAs with const(T) Elements, where T is a value or a reference type respectively. [snip] Questions: (1) Why do I have to specify the type here? Why does

Re: Use dup on Containers with const Elements

2016-07-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/29/16 3:00 PM, Q. Schroll wrote: Cases to consider: Arrays and AAs with const(T) Elements, where T is a value or a reference type respectively. [snip] Questions: (1) Why do I have to specify the type here? Why does inference fail? (2) Why not just S[S]? The copy of a const S is a S so

Use dup on Containers with const Elements

2016-07-29 Thread Q. Schroll via Digitalmars-d-learn
Cases to consider: Arrays and AAs with const(T) Elements, where T is a value or a reference type respectively. class C { } struct S { } const(S)[] varr; const(C)[] carr; const(S)[S] vaav; const(C)[S] caav; const(S)[C] vaac; const(C)[C] caac; pragma(msg,