Adding minmaxElement to Phobos?

Schrom, Brian T Brian.Schrom at
Thu Sep 5 17:08:29 UTC 2019

If someone does do this, an interesting comparison point is how it compares to

auto r = reduce!(min, max)(data);

On 9/5/19, 9:37 AM, "Digitalmars-d on behalf of Andrei Alexandrescu via Digitalmars-d" <digitalmars-d-bounces at on behalf of digitalmars-d at> wrote:

    On 9/5/19 12:12 AM, Per Nordlöw wrote:
    > At
    > I just learned the reason for C++11 having
    > Calculating the min and max simultaneously reduces the number of 
    > comparisons with 1/4.
    > Should we add a minmaxElement alongside minElement and maxElement?
    Looks like enough of an principled algorithm to make a valid addition. I 
    think it was an interview question at Facebook at a point :o). (Hmmm... 
    I looked quickly over the C++ sample implementation in the link above 
    and it seems something is amiss.)

More information about the Digitalmars-d mailing list