std::from_chars output handling

This commit is contained in:
MihailRis 2024-02-01 02:33:38 +03:00
parent e641ebd13b
commit da190f3f7b

View File

@ -26,7 +26,10 @@ int64_t Attribute::asInt() const {
double Attribute::asFloat() const {
double value;
std::from_chars(text.data(), text.data()+text.size(), value);
auto res = std::from_chars(text.data(), text.data()+text.size(), value);
if (res.ptr != text.data()+text.size()) {
throw std::runtime_error("invalid number format "+escape_string(text));
}
return value;
}