Format null ecs::handle as (none)

This commit is contained in:
Nikita Lisitsa 2026-08-14 16:33:40 +03:00
parent 1265b816d3
commit 305d1556c2

View file

@ -29,7 +29,10 @@ namespace psemek::ecs
inline std::ostream & operator << (std::ostream & out, handle const & handle) 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; return out;
} }
@ -55,9 +58,13 @@ namespace std
return ctx.begin(); return ctx.begin();
} }
auto format(::psemek::ecs::handle const & handle, std::format_context & ctx) const template <typename FormatContext>
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);
} }
}; };