Re: shallow copy of const(Object)[]

2014-11-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/31/14 2:38 PM, anonymous wrote: I have a const(Object)[] and I want a shallow copy of the array. ..dup doesn't do it, which I thought a bug, but according to Martin Nowak it's by design [1]. std.array.array fails, too. Is there really nothing in phobos for this? static import std.array;

Re: shallow copy of const(Object)[]

2014-11-02 Thread anonymous via Digitalmars-d-learn
On Sunday, 2 November 2014 at 00:33:53 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: If you want to make sure that a dynamic array refers to new memory and is not a slice of another one, then you'd typically use dup or idup, and in almost all cases, that's exactly what you want. However,

Re: shallow copy of const(Object)[]

2014-11-01 Thread anonymous via Digitalmars-d-learn
On Saturday, 1 November 2014 at 00:08:23 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: So, by shallow copy, you mean that you want an array that contains the same elements but is a new array? yes If that's what you want, just slice the array. auto b = a[]; This is the same as

Re: shallow copy of const(Object)[]

2014-11-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 01, 2014 10:30:05 anonymous via Digitalmars-d-learn wrote: On Saturday, 1 November 2014 at 00:08:23 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: So, by shallow copy, you mean that you want an array that contains the same elements but is a new array? yes

shallow copy of const(Object)[]

2014-10-31 Thread anonymous via Digitalmars-d-learn
I have a const(Object)[] and I want a shallow copy of the array. .dup doesn't do it, which I thought a bug, but according to Martin Nowak it's by design [1]. std.array.array fails, too. Is there really nothing in phobos for this? static import std.array; void main() { const(Object)[] a;

Re: shallow copy of const(Object)[]

2014-10-31 Thread Douglas Petterson via Digitalmars-d-learn
On Friday, 31 October 2014 at 18:39:00 UTC, anonymous wrote: I have a const(Object)[] and I want a shallow copy of the array. .dup doesn't do it, which I thought a bug, but according to Martin Nowak it's by design [1]. std.array.array fails, too. Is there really nothing in phobos for this?

Re: shallow copy of const(Object)[]

2014-10-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, October 31, 2014 18:38:59 anonymous via Digitalmars-d-learn wrote: I have a const(Object)[] and I want a shallow copy of the array. .dup doesn't do it, which I thought a bug, but according to Martin Nowak it's by design [1]. std.array.array fails, too. Is there really nothing in