Skip to content

Commit ce0a559

Browse files
committed
Replace std::from_chars with std::strtod for floats in cli::Reader
std::from_chars for floating-point types is not available in Apple Clang's libc++. Use std::strtod which is locale-independent by default (uses C locale) and works on all platforms.
1 parent 890c8e2 commit ce0a559

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

include/rfl/cli/Reader.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <charconv>
55
#include <concepts>
6+
#include <cstdlib>
67
#include <map>
78
#include <optional>
89
#include <set>
@@ -61,14 +62,13 @@ template <class T> requires (std::is_floating_point_v<T>)
6162
rfl::Result<T> parse_value(
6263
const std::string& _str, const std::string& _path
6364
) noexcept {
64-
T value;
65-
const auto [ptr, ec] =
66-
std::from_chars(_str.data(), _str.data() + _str.size(), value);
67-
if (ec != std::errc() || ptr != _str.data() + _str.size()) {
65+
char* end = nullptr;
66+
const double value = std::strtod(_str.c_str(), &end);
67+
if (end != _str.c_str() + _str.size()) {
6868
return error(
6969
"Could not cast '" + _str + "' to floating point for key '" + _path + "'.");
7070
}
71-
return value;
71+
return static_cast<T>(value);
7272
}
7373

7474
template <class T> requires (std::is_integral_v<T> && !std::same_as<T, bool>)

0 commit comments

Comments
 (0)