Add std::format formatter for ecs::handle

This commit is contained in:
Nikita Lisitsa 2025-04-04 21:07:31 +03:00
parent 57f9f7331c
commit 8099e928dc

View file

@ -3,6 +3,7 @@
#include <psemek/ecs/detail/id.hpp>
#include <iostream>
#include <format>
namespace psemek::ecs
{
@ -46,4 +47,18 @@ namespace std
}
};
template <typename Char>
struct formatter<::psemek::ecs::handle, Char>
{
constexpr auto parse(std::format_parse_context & ctx)
{
return ctx.begin();
}
auto format(::psemek::ecs::handle const & handle, std::format_context & ctx) const
{
return std::format_to(ctx.out(), "({},{})", handle.id, handle.epoch);
}
};
}