8 Oct
2025
8 Oct
'25
1:49 p.m.
Matt Borland wrote:
You may consider from_chars too clumsy, but how do you propose to signal parsing failures given that this library is designed to service environments without exceptions?
If this constructor is to follow the behavior of charconv I think something like this could work:
decimal_t (const std::string& str) { decimal_t x {}; const auto r {from_chars(str, x)}; if (!r) *this = NAN; else
*this = x; }
Please don't. Constructors fail by throwing, not by silently constructing arbitrary values.
No exceptions is definitely a large concern as I know a number of the users run exception free environments.
People who don't want exceptions wouldn't use the constructor.