|
|
@@ -138,6 +138,17 @@ class basic_dispatcher {
|
|
|
return static_cast<handler_type<Type> &>(*ptr);
|
|
|
}
|
|
|
|
|
|
+ template<typename Type>
|
|
|
+ [[nodiscard]] const handler_type<Type> *assure(const id_type id) const {
|
|
|
+ static_assert(std::is_same_v<Type, std::decay_t<Type>>, "Non-decayed types not allowed");
|
|
|
+
|
|
|
+ if(auto it = pools.first().find(id); it != pools.first().cend()) {
|
|
|
+ return static_cast<const handler_type<Type> *>(it->second.get());
|
|
|
+ }
|
|
|
+
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+
|
|
|
public:
|
|
|
/*! @brief Allocator type. */
|
|
|
using allocator_type = Allocator;
|
|
|
@@ -205,11 +216,8 @@ public:
|
|
|
*/
|
|
|
template<typename Type>
|
|
|
size_type size(const id_type id = type_hash<Type>::value()) const noexcept {
|
|
|
- if(auto it = pools.first().find(id); it != pools.first().cend()) {
|
|
|
- return it->second->size();
|
|
|
- }
|
|
|
-
|
|
|
- return 0u;
|
|
|
+ const auto *cpool = assure<std::decay_t<Type>>(id);
|
|
|
+ return cpool ? cpool->size() : 0u;
|
|
|
}
|
|
|
|
|
|
/**
|