From eccfec4b4f804a60b3b1c52315d6a19f73f8bcde Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Fri, 11 Sep 2020 12:06:16 +0200 Subject: [PATCH] registry: use pool_t instead of default_pool --- src/entt/entity/registry.hpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index 8a3ecbf10..1e2c34a7d 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -64,7 +64,7 @@ class basic_registry { void maybe_valid_if(const Entity entt) { [[maybe_unused]] const auto cpools = std::forward_as_tuple(owner->assure()...); - const auto is_valid = ((std::is_same_v || std::get &>(cpools).contains(entt)) && ...) + const auto is_valid = ((std::is_same_v || std::get &>(cpools).contains(entt)) && ...) && ((std::is_same_v || owner->assure().contains(entt)) && ...) && ((std::is_same_v || !owner->assure().contains(entt)) && ...); @@ -75,7 +75,7 @@ class basic_registry { } else { if(is_valid && !(std::get<0>(cpools).index(entt) < current)) { const auto pos = current++; - (std::get &>(cpools).swap(std::get &>(cpools).data()[pos], entt), ...); + (std::get &>(cpools).swap(std::get &>(cpools).data()[pos], entt), ...); } } } @@ -88,7 +88,7 @@ class basic_registry { } else { if(const auto cpools = std::forward_as_tuple(owner->assure()...); std::get<0>(cpools).contains(entt) && (std::get<0>(cpools).index(entt) < current)) { const auto pos = --current; - (std::get &>(cpools).swap(std::get &>(cpools).data()[pos], entt), ...); + (std::get &>(cpools).swap(std::get &>(cpools).data()[pos], entt), ...); } } } @@ -108,7 +108,7 @@ class basic_registry { }; template - [[nodiscard]] const default_pool & assure() const { + [[nodiscard]] const pool_t & assure() const { const sparse_set *cpool; if constexpr(ENTT_FAST_PATH(has_type_index_v)) { @@ -120,7 +120,7 @@ class basic_registry { if(auto &&pdata = pools[index]; !pdata.pool) { pdata.type_id = type_info::id(); - pdata.pool.reset(new default_pool()); + pdata.pool.reset(new pool_t()); } cpool = pools[index].pool.get(); @@ -128,19 +128,19 @@ class basic_registry { if(const auto it = std::find_if(pools.cbegin(), pools.cend(), [id = type_info::id()](const auto &pdata) { return id == pdata.type_id; }); it == pools.cend()) { cpool = pools.emplace_back(pool_data{ type_info::id(), - std::unique_ptr>{new default_pool()} + std::unique_ptr>{new pool_t()} }).pool.get(); } else { cpool = it->pool.get(); } } - return *static_cast *>(cpool); + return *static_cast *>(cpool); } template - [[nodiscard]] default_pool & assure() { - return const_cast &>(std::as_const(*this).template assure()); + [[nodiscard]] pool_t & assure() { + return const_cast &>(std::as_const(*this).template assure()); } Entity generate_identifier() { @@ -1285,9 +1285,9 @@ public: } if constexpr(sizeof...(Owned) == 0) { - return { handler->current, std::get> &>(cpools)... }; + return { handler->current, std::get> &>(cpools)... }; } else { - return { handler->current, std::get> &>(cpools)... , std::get> &>(cpools)... }; + return { handler->current, std::get> &>(cpools)... , std::get> &>(cpools)... }; } }