
10 Mar
2011
10 Mar
'11
5:28 p.m.
Can anyone suggest a better implementation ... for a NaN-preferring min or max ...
template < class T > inline const T& minnan( const T& a, const T& b ) { return a < b || is_nan(a) ? a : b; }
That's much cleaner. Thank you Kris. I've tossed my goofy UNLIKELY macro around the is_nan check just because. It's interesting that when using this minnan() implementation on a sequence of values that short circuiting suggests using the "incumbent" minimum value as the first parameter and the "challenger" candidate value as the second parameter. - Rhys