Commit fafb03fa authored by Victor Zverovich's avatar Victor Zverovich

Fix handling of fallback_uintptr

parent 2f9acd18
...@@ -254,6 +254,12 @@ inline fallback_uintptr to_uintptr(const void* p) { ...@@ -254,6 +254,12 @@ inline fallback_uintptr to_uintptr(const void* p) {
template <typename T> constexpr T max_value() { template <typename T> constexpr T max_value() {
return (std::numeric_limits<T>::max)(); return (std::numeric_limits<T>::max)();
} }
template <typename T> constexpr int digits() {
return std::numeric_limits<T>::digits;
}
template <> constexpr int digits<fallback_uintptr>() {
return sizeof(void*) * std::numeric_limits<unsigned char>::digits;
}
// An approximation of iterator_t for pre-C++20 systems. // An approximation of iterator_t for pre-C++20 systems.
template <typename T> template <typename T>
...@@ -973,7 +979,7 @@ Char* format_uint(Char* buffer, internal::fallback_uintptr n, int num_digits, ...@@ -973,7 +979,7 @@ Char* format_uint(Char* buffer, internal::fallback_uintptr n, int num_digits,
template <unsigned BASE_BITS, typename Char, typename It, typename UInt> template <unsigned BASE_BITS, typename Char, typename It, typename UInt>
inline It format_uint(It out, UInt value, int num_digits, bool upper = false) { inline It format_uint(It out, UInt value, int num_digits, bool upper = false) {
// Buffer should be large enough to hold all digits (digits / BASE_BITS + 1). // Buffer should be large enough to hold all digits (digits / BASE_BITS + 1).
char buffer[std::numeric_limits<UInt>::digits / BASE_BITS + 1]; char buffer[digits<UInt>() / BASE_BITS + 1];
format_uint<BASE_BITS>(buffer, value, num_digits, upper); format_uint<BASE_BITS>(buffer, value, num_digits, upper);
return internal::copy_str<Char>(buffer, buffer + num_digits, out); return internal::copy_str<Char>(buffer, buffer + num_digits, out);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment