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
-
T | is 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. |
- Parameters
-
pszValue | A 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 a conversion from the string pszValue
to the appropriate numeric value. In case of integral T
this is done by Chusov::String::from_string(In_z const ucp_t* pszValue, int base = 10) "another overload" chosen using SFINAE.
- Note
- If a conversion to an arithmetic type takes place, then 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 (for integral T
) when the produced value goes out of valid range of supported values for T
.
- Exceptions
-
- See also
- to_ucp_string(int value)
to_ucp_string(long value)
to_ucp_string(long long value)
to_ucp_string(unsigned value)
to_ucp_string(unsigned long value)
to_ucp_string(unsigned long long value)
to_ucp_string(float value)
to_ucp_string(double value)
to_ucp_string(long double value)
from_string(const ucp_t* pszValue, int base = 10)