Support creating ecs index without passing the container

This commit is contained in:
Nikita Lisitsa 2024-01-10 00:44:23 +03:00
parent 8fcaef4ba1
commit 46a49ef42d

View file

@ -32,6 +32,12 @@ namespace psemek::ecs::detail
storage_.insert({uuid, ptr});
return *ptr;
}
else if constexpr (std::is_constructible_v<Index, Args && ...>)
{
auto ptr = std::make_shared<Index>(std::forward<Args>(args)...);
storage_.insert({uuid, ptr});
return *ptr;
}
else
{
throw util::exception("Index " + util::type_name<Index>() + " is neither present nor constructible");