Add util::fixed_point formatter

This commit is contained in:
Nikita Lisitsa 2026-08-14 16:35:07 +03:00
parent abec5474f0
commit 99063348e3

View file

@ -4,6 +4,7 @@
#include <cstdint> #include <cstdint>
#include <concepts> #include <concepts>
#include <limits> #include <limits>
#include <format>
namespace psemek::util namespace psemek::util
{ {
@ -455,3 +456,21 @@ namespace psemek::util
} }
} }
namespace std
{
template <unsigned int I, unsigned int F, bool S, typename Char>
struct formatter<::psemek::util::fixed_point<I, F, S>, Char>
: formatter<double>
{
using base = formatter<double>;
template <typename FormatContext>
auto format(::psemek::util::fixed_point<I, F, S> const & fp, FormatContext & ctx) const
{
return base::format(static_cast<double>(fp), ctx);
}
};
}