Commit 222f2d28 authored by vitaut's avatar vitaut

Fix MSVC warnings

parent f60c4b99
...@@ -232,6 +232,11 @@ inline DummyInt isinf(...) { return DummyInt(); } ...@@ -232,6 +232,11 @@ inline DummyInt isinf(...) { return DummyInt(); }
inline DummyInt _finite(...) { return DummyInt(); } inline DummyInt _finite(...) { return DummyInt(); }
inline DummyInt isnan(...) { return DummyInt(); } inline DummyInt isnan(...) { return DummyInt(); }
inline DummyInt _isnan(...) { return DummyInt(); } inline DummyInt _isnan(...) { return DummyInt(); }
// A helper function to suppress bogus "conditional expression is constant"
// warnings.
template <typename T>
inline T check(T value) { return value; }
} }
} // namespace fmt } // namespace fmt
...@@ -250,24 +255,28 @@ class numeric_limits<fmt::internal::DummyInt> : ...@@ -250,24 +255,28 @@ class numeric_limits<fmt::internal::DummyInt> :
using namespace fmt::internal; using namespace fmt::internal;
// The resolution "priority" is: // The resolution "priority" is:
// isinf macro > std::isinf > ::isinf > fmt::internal::isinf // isinf macro > std::isinf > ::isinf > fmt::internal::isinf
if (sizeof(isinf(x)) == sizeof(bool) || sizeof(isinf(x)) == sizeof(int)) if (check(sizeof(isinf(x)) == sizeof(bool) ||
sizeof(isinf(x)) == sizeof(int))) {
return isinf(x); return isinf(x);
return !_finite(x); }
return !_finite(static_cast<double>(x));
} }
// Portable version of isnan. // Portable version of isnan.
template <typename T> template <typename T>
static bool isnotanumber(T x) { static bool isnotanumber(T x) {
using namespace fmt::internal; using namespace fmt::internal;
if (sizeof(isnan(x)) == sizeof(bool) || sizeof(isnan(x)) == sizeof(int)) if (check(sizeof(isnan(x)) == sizeof(bool) ||
sizeof(isnan(x)) == sizeof(int))) {
return isnan(x); return isnan(x);
return _isnan(x) != 0; }
return _isnan(static_cast<double>(x)) != 0;
} }
// Portable version of signbit. // Portable version of signbit.
static bool isnegative(double x) { static bool isnegative(double x) {
using namespace fmt::internal; using namespace fmt::internal;
if (sizeof(signbit(x)) == sizeof(int)) if (check(sizeof(signbit(x)) == sizeof(int)))
return signbit(x); return signbit(x);
if (x < 0) return true; if (x < 0) return true;
if (!isnotanumber(x)) return false; if (!isnotanumber(x)) return false;
...@@ -1006,11 +1015,6 @@ struct Not { enum { value = 0 }; }; ...@@ -1006,11 +1015,6 @@ struct Not { enum { value = 0 }; };
template<> template<>
struct Not<false> { enum { value = 1 }; }; struct Not<false> { enum { value = 1 }; };
// A helper function to suppress bogus "conditional expression is constant"
// warnings.
template <typename T>
inline T check(T value) { return value; }
// Makes an Arg object from any type. // Makes an Arg object from any type.
template <typename Char> template <typename Char>
class MakeValue : public Arg { class MakeValue : public Arg {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment