mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 15:21:54 +00:00
Look for isinf in std namespace too.
This commit is contained in:
parent
b09f371306
commit
60d51406ef
15
format.h
15
format.h
@ -167,13 +167,21 @@ inline unsigned CountDigits(uint64_t n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
|
|
||||||
inline int SignBit(double value) {
|
inline int SignBit(double value) {
|
||||||
// When compiled in C++11 mode signbit is no longer a macro but a function
|
// When compiled in C++11 mode signbit is no longer a macro but a function
|
||||||
// defined in namespace std and the macro is undefined.
|
// defined in namespace std and the macro is undefined.
|
||||||
using namespace std;
|
using namespace std;
|
||||||
return signbit(value);
|
return signbit(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline int IsInf(double x) {
|
||||||
|
using namespace std;
|
||||||
|
return isinf(x);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
inline int SignBit(double value) {
|
inline int SignBit(double value) {
|
||||||
if (value < 0) return 1;
|
if (value < 0) return 1;
|
||||||
if (value == value) return 0;
|
if (value == value) return 0;
|
||||||
@ -181,9 +189,12 @@ inline int SignBit(double value) {
|
|||||||
_ecvt(value, 0, &dec, &sign);
|
_ecvt(value, 0, &dec, &sign);
|
||||||
return sign;
|
return sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline int IsInf(double x) { return !_finite(x); }
|
||||||
|
|
||||||
# undef snprintf
|
# undef snprintf
|
||||||
# define snprintf _snprintf
|
# define snprintf _snprintf
|
||||||
# define isinf(x) (!_finite(x))
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
@ -618,7 +629,7 @@ void BasicWriter<Char>::FormatDouble(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isinf(value)) {
|
if (internal::IsInf(value)) {
|
||||||
// Format infinity ourselves because sprintf's output is not consistent
|
// Format infinity ourselves because sprintf's output is not consistent
|
||||||
// across platforms.
|
// across platforms.
|
||||||
std::size_t size = 4;
|
std::size_t size = 4;
|
||||||
|
Loading…
Reference in New Issue
Block a user