fix node::value() not retrieving inf and nan correctly

This commit is contained in:
Mark Gillard 2021-01-05 17:34:18 +02:00
parent 1ef6c0c6c8
commit 00e080f126
2 changed files with 4 additions and 2 deletions

View File

@ -740,7 +740,8 @@ TOML_NAMESPACE_START
else
{
const double val = *ref_cast<double>();
if (val < (std::numeric_limits<T>::lowest)() || val > (std::numeric_limits<T>::max)())
if (impl::fpclassify(val) == fp_class::ok
&& (val < (std::numeric_limits<T>::lowest)() || val > (std::numeric_limits<T>::max)()))
return {};
return { static_cast<T>(val) };
}

View File

@ -3213,7 +3213,8 @@ TOML_NAMESPACE_START
else
{
const double val = *ref_cast<double>();
if (val < (std::numeric_limits<T>::lowest)() || val > (std::numeric_limits<T>::max)())
if (impl::fpclassify(val) == fp_class::ok
&& (val < (std::numeric_limits<T>::lowest)() || val > (std::numeric_limits<T>::max)()))
return {};
return { static_cast<T>(val) };
}