jeudi 31 mars 2016

std::numeric_limits

I was just trying few things on std::numeric_limits. And observed some interesting behaviour. cout << "Min = " << (std::numeric_limits::has_infinity) ? "TRUE" : "FALSE";

outputs "0"

cout << "Min = " << (std::numeric_limits::has_infinity ? "TRUE" : "FALSE"); outputs "FALSE"

Please notice the position of start and end () braces around std::numeric_limits.

In the first case ternary operator didn't had any meaning. Where as when I shift the brace to the end then only ternary operator (?:) is found to be meaningful.

Any inputs on why this behaviour?

Aucun commentaire:

Enregistrer un commentaire