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); } };