15 static_assert(std::is_integral<T>::value,
16 "try_parse_hex only works with integral types (int, long, long long, etc.)");
18 size_t start = 0, end = 0;
21 for (; start < sv.size() && sv[start] ==
' '; start++);
22 for (end = start; end < sv.size() && sv[end] !=
' '; end++);
26 size_t digits = (end - start);
27 size_t base16_exponent = digits - 1;
29 if (digits == 0)
return false;
31 for (
const auto& ch : sv.substr(start, digits)) {
45 digit =
static_cast<int>(ch -
'0');
75 value_ += digit * (T)pow(16, (
double)base16_exponent);
A standalone header file containing shared code.
The all encompassing namespace.
nonstd::string_view string_view
The string_view class used by this library.