From 815e503564f422f7540534854ad75543064debdb Mon Sep 17 00:00:00 2001 From: Luis Michaelis Date: Wed, 27 Dec 2023 20:26:10 +0100 Subject: [PATCH] fix(Archive): only use `std::to_chars` for integers --- src/archive/ArchiveAscii.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/archive/ArchiveAscii.cc b/src/archive/ArchiveAscii.cc index 9ec8ecb9..236d8863 100644 --- a/src/archive/ArchiveAscii.cc +++ b/src/archive/ArchiveAscii.cc @@ -264,7 +264,7 @@ namespace zenkit { } template - std::string_view intosv(std::array& buf, T v) { + std::enable_if_t, std::string_view> intosv(std::array& buf, T v) { auto r = std::to_chars(buf.begin(), buf.end(), v); return std::string_view {buf.begin(), static_cast(r.ptr - buf.begin())}; } @@ -324,9 +324,7 @@ namespace zenkit { } void WriteArchiveAscii::write_float(std::string_view name, float v) { - std::array::max_exponent10 + std::numeric_limits::max_digits10 + 2> - buf {}; - this->write_entry(name, "float", intosv(buf, v)); + this->write_entry(name, "float", std::to_string(v)); } void WriteArchiveAscii::write_byte(std::string_view name, std::uint8_t v) { @@ -400,10 +398,8 @@ namespace zenkit { this->_m_write->write_string(name); this->_m_write->write_string("=rawFloat:"); - std::array::max_exponent10 + std::numeric_limits::max_digits10 + 2> - buf {}; for (auto i = 0u; i < length; ++i) { - this->_m_write->write_string(intosv(buf, v[i])); + this->_m_write->write_string(std::to_string(v[i])); this->_m_write->write_char(' '); }