absl::SimpleAtoi

Converts the given string into an integer value, returning true if successful.

Synopsis

Declared in <absl/strings/numbers.h>

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

Description

The string (optionally followed or preceded by ASCII whitespace) must reflect a base-10 integer whose value falls within the range of the integer type (optionally preceded by a + or -). 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

NameDescription
strThe string to parse.
outThe location that receives the parsed value.