|
noexcept |
Converts a string representation of an integral value to the specified integral representation.
CharType | A type of character of the string containing the integral value. |
IntegralType | An integral type used to hold the numeric representation of data contained within the string. |
first | A pointer to the first character of the sequence representing the number to convert to IntegralType . | |
last | A pointer to the first character after the last element of the sequence. No reads from beyond and including last will be performed by the function. | |
[out] | value | An output parameter to receive the result of conversion. |
base | A base for the conversion. Valid values must be from the range \(\left\[\left.2,36\right)\right.\). For bases from 2 to 9 arabic decimal ascii digit will be considered to represent the converted number in the string. For values of base greater or equal to 10, ascii latin characters will also be considered, both capital and lowercase. Unlike functions like ucpstol, from_chars does not accept 0 as base . |
last
, if there is no such a character.The function does not accept prefixes (i.e. "0x" or "0X" for the base 16) nor does it accept the plus ('+') sign. Only the minus ('-') sign of the number is accepted at the beginning of the string, and only for signed integral types of value
. Other than that, the function behaves identically to the functions like like ucpstol.
If the string does not match the pattern of an integral number the return code (the ec
field of the return value) is std::errc::invalid_argument, and value
remains unchanged.
Otherwise, if the conversion yields an integral overflow, the return code is std::errc::result_out_of_range. Likewise, value
remains unchanged.
Otherwise, if the functions succeeds, the return code is a value-initialized std::errc code.
This is an implementation of the C++17 std::from_chars functions using means of C++14 and supporting strings of characters other than just char
.