Peter Alexander:
It's tricky. The only way (that I'm aware of) to get it to
return NaN is to explicitly test for NaN, introducing overhead
that is unnecessary 99.9% of the time.
Unfortunately this is one of those situations where D's design
goals of efficiency and safety are at odds. You can't have it
both ways.
Few possibilities:
1) Add a second NaN-aware function pair nmax()/nmin();
2) Add a debug{} inside min()/max(), where NaNs are managed;
3) Introduce a if(version=NaNAware){} block inside the normal
max()/min() and other Phobos functions, to be used when you want
more NaN-correct results.
I prefer the third idea, but this probably requires a
recompilation of Phobos.
Bye,
bearophile