fmt: support numeric u128 formatting

This commit is contained in:
Nekotekina 2021-04-24 15:28:15 +03:00
parent 4d9a167f56
commit b5e9f09972
2 changed files with 99 additions and 20 deletions

View file

@ -254,6 +254,13 @@ void fmt_class_string<u128>::format(std::string& out, u64 arg)
{
// TODO: it should be supported as full-fledged integral type (with %u, %d, etc, fmt)
const u128& num = get_object(arg);
if (!num)
{
out += '0';
return;
}
#ifdef _MSC_VER
fmt::append(out, "0x%016llx%016llx", num.hi, num.lo);
#else
@ -261,6 +268,12 @@ void fmt_class_string<u128>::format(std::string& out, u64 arg)
#endif
}
template <>
void fmt_class_string<s128>::format(std::string& out, u64 arg)
{
return fmt_class_string<u128>::format(out, arg);
}
template <>
void fmt_class_string<src_loc>::format(std::string& out, u64 arg)
{
@ -375,6 +388,8 @@ struct fmt::cfmt_src
TYPE(short);
if (std::is_signed<char>::value) TYPE(char);
TYPE(long);
TYPE(u128);
TYPE(s128);
#undef TYPE