17#ifndef TOOLBOX_UTIL_UTILITY_HPP
18#define TOOLBOX_UTIL_UTILITY_HPP
27inline namespace util {
32template <
typename ValueT>
40 return c >=
'0' &&
c <=
'9';
51 return i < 10000000000 ?
i < 100000 ?
i < 100 ?
i < 10 ? 1 : 2
55 :
i < 10000000 ?
i < 1000000 ? 6 : 7
59 :
i < 1000000000000000 ?
i < 1000000000000 ?
i < 100000000000 ? 11 : 12
60 :
i < 10000000000000 ? 13
61 :
i < 100000000000000 ? 14
63 :
i < 100000000000000000 ?
i < 10000000000000000 ? 16 : 17
64 :
i < 1000000000000000000 ? 18
74template <
typename UIntegerT>
75 requires std::unsigned_integral<UIntegerT>
78 constexpr auto Bits =
sizeof(
i) * 8;
79 return 1 + ((
Bits - std::countl_zero(
i | 1) - 1) >> 2);
84static_assert(
hex_digits(std::uint64_t{0xffffffffffff}) == 12);
89template <
typename ValueT>
90 requires std::integral<ValueT> || std::same_as<ValueT, double>
93 if constexpr (std::is_same_v<ValueT, double>) {
95 }
else if constexpr (std::is_integral_v<ValueT>) {
96 auto it =
sv.begin(), end =
sv.end();
101 if constexpr (std::is_signed_v<ValueT>) {
123static_assert(
ston<int>(std::string_view{
"-123"}) == -123);