chsvlib
chsv helper source code

◆ stoi()

int Chusov::String::stoi ( const ucp_string str,
std::size_t *restrict  pos = nullptr,
int  base = 10 
)

Converts a UCP string to int.

Parameters
strA string to convert.
[out]posAn optional buffer receiving the amount of characters successfully converted to int.
baseA base of the string representation of the integral number.
Returns
The converted integral value.

The function behaves identically to the call

ucptol(str.c_str(), ptr, base)

(where on output

ptr == str.c_str()

, and the return valus is cast to int), but instead of returning an error code the function throws as follows.

Exceptions
std::invalid_argumentThe input string does not match a pattern of an integral number.
std::out_of_rangeThe result of conversion has caused an integral overflow.

The function behaves like std::stoi does for the char characters but accepts ucp_t characters instead.