chsvlib
chsv helper source code

◆ from_string() [2/9]

T Chusov::String::from_string ( const char *  pszValue,
int  base = 10 
)

A set of templates providing an interface to convert an argument specifying a C or C++ string to a value of a specified type. This template is available (i.e. participates in overload resolution) when the type is integral. .

Template Parameters
Tis a type for the string value to convert to. The type T must be either constructible from pszValue directly or be one of the fundamental arithmetic types. Particularly this overload is chosen when T is integral.
Parameters
pszValueA C-string containing the value to convert.
baseA base in which the integral numeric value is expected in pszValue.
Returns
The resulting value. The function redirects the call to one of the standard integral conversion functions.

If the function is called with one argument and non-integral T, the other version of from_string will be chosen using SFINAE.

Note
Unlike C and C++ library conversion functions, this function fails, if pszValue is an empty string, or if not the entire pszValue can be converted into the type T, because of parsing errors and when the produced value goes out of valid range of supported values for T.
Exceptions
Chusov::Exceptions::InvalidParameterExceptionParsing or range error occurred during the conversion to T.