All functions named to_chars
convert value into a character string
by successively filling the range
where [first, last) is required to be a valid range.
If the member ec
of the return value
is such that the value
is equal to the value of a value-initialized errc,
the conversion was successful
and the member ptr
is the one-past-the-end pointer of the characters written.
the member ec has the value errc::value_too_large,
the member ptr has the value last,
and the contents of the range [first, last) are unspecified.
The functions that take a floating-point value
but not a precision parameter
ensure that the string representation
consists of the smallest number of characters
there is at least one digit before the radix point (if present) and
parsing the representation using the corresponding from_chars function
recovers value exactly.
This guarantee applies only if
to_chars and from_chars
are executed on the same implementation.
— end note]
If there are several such representations,
the representation with the smallest difference from
the floating-point argument value is chosen,
resolving any remaining ties using rounding according to
The functions taking a chars_format parameter
determine the conversion specifier for printf as follows:
The conversion specifier is
f if fmt is chars_format::fixed,
e if fmt is chars_format::scientific,
a (without leading "0x" in the result)
if fmt is chars_format::hex,
g if fmt is chars_format::general.