From 8cccb4ce5ca1d1c1294b8269fd5807690464d315 Mon Sep 17 00:00:00 2001 From: HJfod Date: Sun, 18 Feb 2024 00:13:34 +0200 Subject: [PATCH] fix numFromString on floats --- loader/include/Geode/utils/general.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/loader/include/Geode/utils/general.hpp b/loader/include/Geode/utils/general.hpp index 1260197e..abc66007 100644 --- a/loader/include/Geode/utils/general.hpp +++ b/loader/include/Geode/utils/general.hpp @@ -105,7 +105,13 @@ namespace geode { template Result numFromString(std::string_view const str, int base = 10) { Num result; - auto [_, ec] = std::from_chars(str.data(), str.data() + str.size(), result, base); + std::errc ec; + if constexpr (std::is_floating_point_v) { + ec = std::from_chars(str.data(), str.data() + str.size(), result).ec; + } + else { + ec = std::from_chars(str.data(), str.data() + str.size(), result, base).ec; + } switch (ec) { case std::errc(): return Ok(result); case std::errc::invalid_argument: return Err("String is not a number");