chsvlib
chsv helper source code

◆ from_string() [3/9]

T Chusov::String::from_string ( const std::basic_string< CharT, TraitsT, AllocT > &  strValue)

A set of templates providing an interface to convert an argument specifying a C or C++ string to a value of a specified type. .

Template Parameters
Tis a type for the string value to convert to. The type T must be either constructible from strValue directly or be one of the fundamental arithmetic types.
CharTA deduced type of a character of the string. It must be either char or wchar_t.
TraitsTA deduced traits type used by the string.
AllocTA deduced allocator type used by the string.
Parameters
strValueA C++ string containing the value to convert.
Returns
The resulting value. If the type T is constructible from the parameter, the appropriate constructor is called to produce the return value. Otherwise, if T is one of the arithmetic types, the call is redirected to overloads of from_string accepting char or wchar_t based C-strings.
Note
If a conversion to an arithmetic type takes place, then unlike C and C++ library conversion functions, this function fails, if strValue is an empty string, or if not the entire strValue can be converted into the type T, because of parsing errors and (for integral T) when the produced value goes out of valid range of supported values for T.
Exceptions
Chusov::Exceptions::InvalidParameterExceptionParsing or range error occurred during a conversion to an arithmetic T.