From 8099e928dc5b35bacf10f0e1119e675d42df6883 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Fri, 4 Apr 2025 21:07:31 +0300 Subject: [PATCH] Add std::format formatter for ecs::handle --- libs/ecs/include/psemek/ecs/handle.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libs/ecs/include/psemek/ecs/handle.hpp b/libs/ecs/include/psemek/ecs/handle.hpp index ef2c054d..2066ad01 100644 --- a/libs/ecs/include/psemek/ecs/handle.hpp +++ b/libs/ecs/include/psemek/ecs/handle.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace psemek::ecs { @@ -46,4 +47,18 @@ namespace std } }; + template + 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); + } + }; + }