Adding minmaxElement to Phobos?

Gregor Mückl gregormueckl at gmx.de
Fri Sep 6 15:29:51 UTC 2019


On Wednesday, 4 September 2019 at 22:12:28 UTC, Per Nordlöw wrote:
> At
>
> https://stackoverflow.com/a/19954882/683710
>
> I just learned the reason for C++11 having
>
> https://en.cppreference.com/w/cpp/algorithm/minmax_element
>
> Calculating the min and max simultaneously reduces the number 
> of comparisons with 1/4.
>
> Should we add a minmaxElement alongside minElement and 
> maxElement?

Side note: a stride of two as in the StackOverflow example code 
would be suboptimal as this should prevent vectorization of the 
loop. The stride probably needs to be the width of a SIMD 
register to gain any advantage over the naive loop.


More information about the Digitalmars-d mailing list