Don't pass ill-formed strings to stold

* Avoid exceptions coming out of stold.
* from_stream should always set failbit instead of throw.
This commit is contained in:
Howard Hinnant
2017-07-06 11:54:55 -04:00
parent 0c8b1f5967
commit 6067371127

3
date.h
View File

@@ -5334,7 +5334,10 @@ read_long_double(std::basic_istream<CharT, Traits>& is, unsigned m = 1, unsigned
break;
}
if (count < m)
{
is.setstate(std::ios::failbit);
return 0;
}
return std::stold(buf);
}