Просмотр исходного кода

registry: pass the allocator to the pools

Michele Caini 3 лет назад
Родитель
Сommit
cf12765738
2 измененных файлов с 6 добавлено и 3 удалено
  1. 3 0
      TODO
  2. 3 3
      src/entt/entity/registry.hpp

+ 3 - 0
TODO

@@ -11,6 +11,9 @@ DOC:
 * examples (and credits) from @alanjfs :)
 * update entity doc when the storage based model is in place
 
+TODO (high prio):
+* remove the static storage from the const assure in the registry
+
 WIP:
 * get rid of observers, storage based views made them pointless - document alternatives
 * add storage getter for filters to views and groups

+ 3 - 3
src/entt/entity/registry.hpp

@@ -255,7 +255,7 @@ class basic_registry {
     using entity_traits = entt_traits<Entity>;
 
     template<typename Type>
-    using storage_for_type = typename storage_for<Type, Entity>::type;
+    using storage_for_type = typename storage_for<Type, Entity, typename alloc_traits::template rebind_alloc<std::remove_const_t<Type>>>::type;
 
     template<typename...>
     struct group_handler;
@@ -312,7 +312,7 @@ class basic_registry {
         auto &cpool = pools[id];
 
         if(!cpool) {
-            cpool.reset(new storage_for_type<Type>{});
+            cpool.reset(new storage_for_type<Type>{get_allocator()});
             cpool->bind(forward_as_any(*this));
         }
 
@@ -329,7 +329,7 @@ class basic_registry {
             return static_cast<const storage_for_type<Type> &>(*it->second);
         }
 
-        static storage_for_type<Type> placeholder{};
+        static storage_for_type<Type> placeholder{get_allocator()};
         return placeholder;
     }