8 Oct
2025
8 Oct
'25
4:58 p.m.
10-08 14:59, Matt Borland via Boost a écrit :
What about something like the following:
decimal64_t dec = make_decimal64(const std::string&)
or decimal64_t dec = make_decimal64(std::string_view)
This could assume C locale like from_chars to avoid strtod surprises, be more ergonomic than from_chars, and allow leading "+" like strtod.
How do you report failure ? Shouldn't it return an expected-like for that purpose ?
I maintain NAN is the way to go for reporting failure here, and I won't be scolded for returning that from the constructor. NAN is designed to represent undefined or unrepresentable values. I would argue that an unparseable or any bad string is an undefined/unrepresentable value and thus a NAN. Matt