Why is std.algorithm so complicated to use?

Jonathan M Davis jmdavisProg at gmx.com
Sun Jul 15 17:01:48 PDT 2012


On Monday, July 16, 2012 01:47:15 Mehrdad wrote:
> On Sunday, 15 July 2012 at 22:39:47 UTC, Jonathan M Davis wrote:
> > On Sunday, July 15, 2012 18:24:47 Andrei Alexandrescu wrote:
> >> On 7/15/12 6:22 PM, Mehrdad wrote:
> >> > On Sunday, 15 July 2012 at 22:03:33 UTC, Jonathan M Davis
> >> > 
> >> > wrote:
> >> >> auto arr = [10, 22, 19, 4, 6];
> >> >> arr = remove(arr, 3);
> >> >> assert(arr == [10, 22, 19, 6]);
> >> > 
> >> > Yeah, the problem is that this reallocates...
> >> 
> >> doesn't
> > 
> > Yeah. It just slices.
> 
> Ooooooh, I misunderstood what was happening. Thanks to both you &
> Andrei!

std.algorithm.remove does pretty much exactly what the STL's erase function 
does, only it operates on ranges rather than iterators.

- Jonathan M Davis


More information about the Digitalmars-d mailing list