diff --git a/include/nlohmann/detail/view/serializer.hpp b/include/nlohmann/detail/view/serializer.hpp index eeff92851..8e5c6dc1c 100644 --- a/include/nlohmann/detail/view/serializer.hpp +++ b/include/nlohmann/detail/view/serializer.hpp @@ -257,6 +257,8 @@ class view_serializer using nav = navigation; using string_t = typename BasicJsonType::string_t; using number_float_t = typename BasicJsonType::number_float_t; + /// doubles that are IEEE 754 binary64 are written from their bits (Zmij) + using fast_double = std::integral_constant < bool, std::is_same::value && ::nlohmann::detail::dtoa_impl::is_binary64::value >; public: view_serializer(const document_data& d, string_t& out, std::size_t estimate, const dump_style& style) @@ -526,7 +528,7 @@ class view_serializer room(n->len); copy(src + n->off, n->len); } - else if (enabled(std::is_same::value)) + else if (enabled(fast_double::value)) { room(64); w = write_double_at(w, *n); @@ -716,7 +718,7 @@ class view_serializer /// a float node as dump() writes it void write_float_node(const node& n) { - write_float_node(n, std::is_same {}); + write_float_node(n, fast_double {}); } void write_float_node(const node& n, std::false_type /*other*/) diff --git a/single_include/nlohmann/json_view.hpp b/single_include/nlohmann/json_view.hpp index a39e14931..70b390810 100644 --- a/single_include/nlohmann/json_view.hpp +++ b/single_include/nlohmann/json_view.hpp @@ -6072,6 +6072,8 @@ class view_serializer using nav = navigation; using string_t = typename BasicJsonType::string_t; using number_float_t = typename BasicJsonType::number_float_t; + /// doubles that are IEEE 754 binary64 are written from their bits (Zmij) + using fast_double = std::integral_constant < bool, std::is_same::value && ::nlohmann::detail::dtoa_impl::is_binary64::value >; public: view_serializer(const document_data& d, string_t& out, std::size_t estimate, const dump_style& style) @@ -6341,7 +6343,7 @@ class view_serializer room(n->len); copy(src + n->off, n->len); } - else if (enabled(std::is_same::value)) + else if (enabled(fast_double::value)) { room(64); w = write_double_at(w, *n); @@ -6531,7 +6533,7 @@ class view_serializer /// a float node as dump() writes it void write_float_node(const node& n) { - write_float_node(n, std::is_same {}); + write_float_node(n, fast_double {}); } void write_float_node(const node& n, std::false_type /*other*/)