diff --git a/src/entt/signal/emitter.hpp b/src/entt/signal/emitter.hpp index 14b0fccc5..9075bac38 100644 --- a/src/entt/signal/emitter.hpp +++ b/src/entt/signal/emitter.hpp @@ -127,17 +127,23 @@ class emitter { template const pool_handler & assure() const { static_assert(std::is_same_v>); - const auto index = type_index::value(); - if(!(index < pools.size())) { - pools.resize(index+1); + if constexpr(has_type_index_v) { + const auto index = type_index::value(); + + if(!(index < pools.size())) { + pools.resize(index+1); + } + + if(!pools[index]) { + pools[index].reset(new pool_handler{}); + } + + return static_cast &>(*pools[index]); + } else { + auto it = std::find_if(pools.begin(), pools.end(), [id = type_info::id()](const auto &cpool) { return id == cpool->type_id(); }); + return static_cast &>(it == pools.cend() ? *pools.emplace_back(new pool_handler{}) : **it); } - - if(!pools[index]) { - pools[index].reset(new pool_handler{}); - } - - return static_cast &>(*pools[index]); } template