BloombergLP::bslstl::to_chars

Write the specified value into the character buffer [first, last)].

Synopsis

Declared in <bslstl_charconv.h>

template<class INTEGRAL_TYPE>
to_chars_result
to_chars(
    char* first,
    char* last,
    INTEGRAL_TYPE value,
    int base = 10);

Description

Optionally specify base, the base in which the number is to be written. If base is not specified, decimal is used. Return a to_chars_result struct indicating success or failure, and the end of the written result. On success, the output string is to begin at first, the ptr field in the return value is to point at the end of the representation, and the ec field will be 0. If the buffer specified by [ first .. last )] is not large enough for the result, return a struct with ptr set to last and ec set to errc::value_too_large. Insufficient room in the output buffer is the only failure mode. The behavior is undefined unless first < last and base is in the range [ 2 .. 36 ].

Return Value

a to_chars_result indicating success or failure and the end of the written representation

Parameters

NameDescription
firstbeginning of the character buffer to write into
lastend of the character buffer to write into
valueintegral value to convert to characters
basenumeric base for the conversion, in the range [2 .. 36]