Fix parsing floating-point literals on clang

This commit is contained in:
Nikita Lisitsa 2026-01-05 00:04:25 +03:00
parent e5b11fd707
commit 45e19e47b2

View file

@ -48,7 +48,12 @@ template <typename T>
{ {
T value; T value;
#ifdef __clang__ #ifdef __clang__
value = std::strtoll(str.data(), nullptr, 10); if constexpr (std::is_floating_point_v<T>)
value = std::atof(str.data());
else if constexpr (std::is_signed_v<T>)
value = std::strtoll(str.data(), nullptr, 10);
else
value = std::strtoull(str.data(), nullptr, 10);
#else #else
auto result = std::from_chars(str.data(), str.data() + str.size(), value); auto result = std::from_chars(str.data(), str.data() + str.size(), value);
if (result.ec != std::errc()) if (result.ec != std::errc())