Converts a hexadecimal string to an integer, returning true if successful.

Synopsis

Declared in <absl/strings/numbers.h>

template<typename int_type>
[[nodiscard]]
bool
SimpleHexAtoi(
    std::string_view str,
    int_type* out);

Description

The string (optionally followed or preceded by ASCII whitespace) must be a valid base‐16 hexadecimal integer whose value falls within the range of the integer type (optionally preceded by a + or ). A valid hexadecimal value may include both upper and lowercase character symbols, and may optionally include a leading "0x" (or "0X") number prefix, which is ignored by this function. If any errors are encountered, this function returns false, leaving out in an unspecified state.

Return Value

true on success; otherwise false.

Note

The return value should not be discarded.

Parameters

Name

Description

str

The string to parse.

out

The location that receives the parsed value.

Created with MrDocs