std.algorithm imporvments

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Jul 16 15:42:46 PDT 2012


On 7/16/12 6:43 AM, monarch_dodra wrote:
> I had a discussion recently about the proper use of "save" when passing
> to foreach or algorithms, as well as read the thread about algorithms
> being hard to use. It was concluded this the problem mostly came from:
> a) Lack of proper testing.
> b) Missing or inaccurate input type checking.
>
> I decided to donate some of my time to investigate and improve on both
> these points.
>
> Here is what I found:
>
> *"Save" issues:
> *"minPos". Atsolutly no backup is ever made, and this method will return
> an empty range ALL the time.
> *"fill(Range1, Range2)". Save occurs only once, but not within loop
> body. An out of range exception occurs should Range1.length > 2*
> Range2.length.
[snip]

Wow, this is awesome. Did you discover that by inspection or by testing? 
I think a "malicious input range" would be a great tool for assessing 
which algorithms fail on input ranges.

Andrei



More information about the Digitalmars-d mailing list