2011/3/10 Rhys Ulerich <rhys.ulerich@gmail.com>
> inline const T& minnan( const T& a, const T& b )
> {
> template < class T >
>   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.

 
I'm no expert in this, but I'd expect a modern compiler to generate for a modern procesor such code, that would check both conditions parallel somehow, i.e. in different instruction pipelines. So I wouldn't expect UNLIKELY or short circuiting to make a defference.. I'd expect UNLIKELY to kick-in well in situations, the conditional branches are larger. And I'd expect short circuiting to make a defference in situations, where the calculations of the condithis are large (or have sideeffects). But only measurements can tell for sure ;-)

Regards,
Kris