mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-26 02:21:34 +08:00
Minor improvment to number padding
This commit is contained in:
parent
fc900e2432
commit
ca9c83f824
@ -63,11 +63,9 @@ template<typename T>
|
|||||||
inline void pad_uint(T n, unsigned int width, memory_buf_t &dest)
|
inline void pad_uint(T n, unsigned int width, memory_buf_t &dest)
|
||||||
{
|
{
|
||||||
static_assert(std::is_unsigned<T>::value, "pad_uint must get unsigned T");
|
static_assert(std::is_unsigned<T>::value, "pad_uint must get unsigned T");
|
||||||
auto digits = count_digits(n);
|
for(auto digits = count_digits(n); digits < width; digits++)
|
||||||
if (width > digits)
|
|
||||||
{
|
{
|
||||||
const char *zeroes = "0000000000000000000";
|
dest.push_back('0');
|
||||||
dest.append(zeroes, zeroes + width - digits);
|
|
||||||
}
|
}
|
||||||
append_int(n, dest);
|
append_int(n, dest);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user