Template Function sequant::string_to(std::string_view, int)¶
Defined in File conversion.hpp
Function Documentation¶
-
template<std::integral T>
T sequant::string_to(std::string_view str, int base = 10)¶ Converts the provided string to the desired integral type. Contrary to standard functions, this function does perform explicit error checking and will throw a ConversionException if the provided string can’t be parsed in its entirety (no partial conversions, no whitespace skipping!). The function will also throw if the parsed value can’t be represented within the range of T.
- Template Parameters:
T – The integral type one wishes to obtain
- Parameters:
str – The string to convert
base – The base used to represent the value in its string format
- Throws:
ConversionException – in case the conversion is unsuccessful or the parsed value can’t be represented as a T.
- Returns:
The parsed value