From 305d1556c2e86c3372868a470975ec71ccbc0818 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Fri, 14 Aug 2026 16:33:40 +0300 Subject: [PATCH] Format null ecs::handle as (none) --- libs/ecs/include/psemek/ecs/handle.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libs/ecs/include/psemek/ecs/handle.hpp b/libs/ecs/include/psemek/ecs/handle.hpp index 2066ad01..6cd6ecbc 100644 --- a/libs/ecs/include/psemek/ecs/handle.hpp +++ b/libs/ecs/include/psemek/ecs/handle.hpp @@ -29,7 +29,10 @@ namespace psemek::ecs inline std::ostream & operator << (std::ostream & out, handle const & handle) { - out << '(' << handle.id << ',' << handle.epoch << ')'; + if (!handle) + out << "(none)"; + else + out << '(' << handle.id << ',' << handle.epoch << ')'; return out; } @@ -55,9 +58,13 @@ namespace std return ctx.begin(); } - auto format(::psemek::ecs::handle const & handle, std::format_context & ctx) const + template + auto format(::psemek::ecs::handle const & handle, FormatContext & ctx) const { - return std::format_to(ctx.out(), "({},{})", handle.id, handle.epoch); + if (!handle) + return std::format_to(ctx.out(), "(none)"); + else + return std::format_to(ctx.out(), "({},{})", handle.id, handle.epoch); } };