
17 Jan
2025
17 Jan
'25
8:01 p.m.
Another quick question:
decimal::to_chars returns a structure that contains an error code and a pointer, implying that the function can fail. Having a quick glance at the implementation, it returns an error code if an invalid character range is supplied (e.g. end_pointer < begin_pointer). Other than that, can to_chars fail anyhow?
It's designed to match the STL interface (and you can use the STL interface if you want with >= C++17). The only other fail case is not being able to fit the printed value in the buffer at the specified precision (or precision 6 for unspecified). You get std::errc::value_too_large in that case. Matt