mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
std::from_chars output handling
This commit is contained in:
parent
e641ebd13b
commit
da190f3f7b
1 changed files with 4 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue