Re: Unmanaged drop in replacemet for [] and length -= 1

2016-06-20 Thread Joerg Joergonson via Digitalmars-d-learn
On Monday, 20 June 2016 at 16:27:29 UTC, Steven Schveighoffer wrote: On 6/18/16 5:55 PM, Joerg Joergonson wrote: I wanted to switch to std.container.Array but it doesn't seem to mimic [] for some odd ball reason. I threw this class together and it seems to work. The only problem is that I can

Re: Unmanaged drop in replacemet for [] and length -= 1

2016-06-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/18/16 5:55 PM, Joerg Joergonson wrote: I wanted to switch to std.container.Array but it doesn't seem to mimic [] for some odd ball reason. I threw this class together and it seems to work. The only problem is that I can't do carray.length -= 1; I can't override `-=` because that is on the

Re: Unmanaged drop in replacemet for [] and length -= 1

2016-06-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, June 19, 2016 15:59:41 Joerg Joergonson via Digitalmars-d-learn wrote: > If foreach removes all/any of the elements of a container then > something is broke. That's exactly what happens with a basic input range, and if it doesn't happen with a forward range, it's just because copying t

Re: Unmanaged drop in replacemet for [] and length -= 1

2016-06-19 Thread Joerg Joergonson via Digitalmars-d-learn
On Sunday, 19 June 2016 at 10:10:54 UTC, Jonathan M Davis wrote: On Saturday, June 18, 2016 21:55:31 Joerg Joergonson via Digitalmars-d-learn wrote: I wanted to switch to std.container.Array but it doesn't seem to mimic [] for some odd ball reason. D's dynamic arrays are really quite weird in

Re: Unmanaged drop in replacemet for [] and length -= 1

2016-06-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, June 18, 2016 21:55:31 Joerg Joergonson via Digitalmars-d-learn wrote: > I wanted to switch to std.container.Array but it doesn't seem to > mimic [] for some odd ball reason. D's dynamic arrays are really quite weird in that they're sort of containers and sort of not. So, pretty much

Re: Unmanaged drop in replacemet for [] and length -= 1

2016-06-18 Thread Joerg Joergonson via Digitalmars-d-learn
Also, how to handle foreach(i, x; w) (use index + value)?

Unmanaged drop in replacemet for [] and length -= 1

2016-06-18 Thread Joerg Joergonson via Digitalmars-d-learn
I wanted to switch to std.container.Array but it doesn't seem to mimic [] for some odd ball reason. I threw this class together and it seems to work. The only problem is that I can't do carray.length -= 1; I can't override `-=` because that is on the class. can I override it for length someh