Fix parsing floating-point literals on clang
This commit is contained in:
parent
e5b11fd707
commit
45e19e47b2
1 changed files with 6 additions and 1 deletions
|
|
@ -48,7 +48,12 @@ template <typename T>
|
||||||
{
|
{
|
||||||
T value;
|
T value;
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
|
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);
|
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())
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue