Skip to content

Commit

Permalink
dont reinvent the wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
altalk23 authored Oct 4, 2024
1 parent 9e82cee commit d4ca28c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion loader/include/Geode/utils/general.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ namespace geode {
if constexpr (std::is_floating_point_v<Num>) res = std::from_chars(str.data(), str.data() + str.size(), result);
else res = std::from_chars(str.data(), str.data() + str.size(), result, base);

auto [_, ec] = res;
auto [ptr, ec] = res;
if (ec == std::errc()) return Ok(result);
else if (ptr != str.data() + str.size()) return Err("String contains trailing extra data");
else if (ec == std::errc::invalid_argument) return Err("String is not a number");
else if (ec == std::errc::result_out_of_range) return Err("Number is too large to fit");
else return Err("Unknown error");
Expand Down

0 comments on commit d4ca28c

Please sign in to comment.