mardi 8 novembre 2022

Different results of std::isinf for different types and different compilers

Compiling with MSVC(v19.33), this does not compile (C2668 ambiguous call to overloaded function):

std::cout << std::isinf(0) << std::endl;

But this compiles:

std::cout << std::isinf(0.0) << std::endl;

However, in cppreference.com, it says:

  1. A set of overloads or a function template accepting the arg argument of any integral type. Equivalent to (2) (the argument is cast to double).

It seems like the function has existed in the standard since C++11.

If I understood correctly, the first code should be equivalent to the second one, shouldn't it? Does this mean MSVC hasn't implemented the overloaded functions yet, or am I missing something?

(In contrast, if I use gcc or clang, the above examples compile without problems).

Aucun commentaire:

Enregistrer un commentaire