From c1f5f0451d098263d00cfb8c71b3dd74f1327e80 Mon Sep 17 00:00:00 2001 From: Trevor Welsby Date: Sun, 24 Jan 2016 17:54:50 +1000 Subject: [PATCH] Add workaround for gcc < 5 not supporting std::defaultfloat --- src/json.hpp | 5 ++++- src/json.hpp.re2c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 1b1939c4..cf69dff6 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -5544,7 +5544,10 @@ class basic_json // 15 digits of precision allows round-trip IEEE 754 string->double->string; // to be safe, we read this value from std::numeric_limits::digits10 if (std::fmod(m_value.number_float, 1) == 0) o << std::fixed << std::setprecision(1); - else o << std::defaultfloat << std::setprecision(std::numeric_limits::digits10); + else { + o.unsetf(std::ios_base::floatfield); // std::defaultfloat not supported in gcc version < 5 + o << std::setprecision(std::numeric_limits::digits10); + } o << m_value.number_float; return; } diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 873f9be8..c6046d15 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -5544,7 +5544,10 @@ class basic_json // 15 digits of precision allows round-trip IEEE 754 string->double->string; // to be safe, we read this value from std::numeric_limits::digits10 if (std::fmod(m_value.number_float, 1) == 0) o << std::fixed << std::setprecision(1); - else o << std::defaultfloat << std::setprecision(std::numeric_limits::digits10); + else { + o.unsetf(std::ios_base::floatfield); // std::defaultfloat not supported in gcc version < 5 + o << std::setprecision(std::numeric_limits::digits10); + } o << m_value.number_float; return; }