From 0e352cb4662abd161ea4c89ec0f401433cecb382 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Fri, 1 Nov 2019 16:56:53 +0100 Subject: [PATCH] single component registry::prepare with arguments (suitable for custom pools) --- src/entt/entity/registry.hpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index 52e363c3d..9cb811fd1 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -239,8 +239,8 @@ class basic_registry { destroyed = Entity{entt}; } - template - const pool_type * assure() const { + template + const pool_type * assure(Args &&... args) const { const auto ctype = to_integer(type()); pool_data *pdata = nullptr; @@ -264,7 +264,7 @@ class basic_registry { if(!pdata->pool) { pdata->runtime_type = ctype; - pdata->pool = std::make_unique>(); + pdata->pool = std::make_unique>(std::forward(args)...); pdata->remove = [](sparse_set &cpool, basic_registry &owner, const Entity entt) { static_cast &>(cpool).remove(owner, entt); @@ -324,12 +324,14 @@ public: } /** - * @brief Prepares pools for the given types if required. - * @tparam Component Types of components for which to prepare pools. + * @brief Prepares a pool for the given type if required. + * @tparam Component Type of component for which to prepare a pool. + * @tparam Args Types of arguments to use to prepare the pool. + * @param args Parameters to use to initialize the pool. */ - template - void prepare() { - (assure(), ...); + template + void prepare(Args &&... args) { + assure(std::forward(args)...); } /**