Boost logo

Boost :

From: Matt Borland (matt_at_[hidden])
Date: 2025-01-17 20:01:45


> 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






Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk