diff --git a/format.cc b/format.cc index 2790e3b6..3f5d8080 100644 --- a/format.cc +++ b/format.cc @@ -118,6 +118,8 @@ void ReportError(FormatFunc func, } } // namespace +int fmt::internal::SignBitNoInline(double value) { return SignBit(value); } + template int fmt::internal::CharTraits::FormatFloat( char *buffer, std::size_t size, const char *format, diff --git a/format.h b/format.h index 0fbddde6..dcfde293 100644 --- a/format.h +++ b/format.h @@ -399,6 +399,8 @@ inline bool IsNegative(T value) { return SignChecker::is_signed>::IsNegative(value); } +int SignBitNoInline(double value); + template struct IntTraits { // Smallest of uint32_t and uint64_t that is large enough to represent diff --git a/test/format-test.cc b/test/format-test.cc index ece86785..07872dd8 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1235,8 +1235,7 @@ TEST(FormatterTest, FormatNaN) { double nan = std::numeric_limits::quiet_NaN(); EXPECT_EQ("nan", str(Format("{}") << nan)); EXPECT_EQ("+nan", str(Format("{:+}") << nan)); - using namespace std; - if (signbit(-nan)) + if (fmt::internal::SignBitNoInline(-nan)) EXPECT_EQ("-nan", str(Format("{}") << -nan)); else fmt::Print("Warning: compiler doesn't handle negative NaN correctly");