Quellcode durchsuchen

registry: strict check on value_type for allocators

Michele Caini vor 3 Jahren
Ursprung
Commit
1e36b6c4b6
1 geänderte Dateien mit 3 neuen und 2 gelöschten Zeilen
  1. 3 2
      src/entt/entity/registry.hpp

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

@@ -249,9 +249,10 @@ private:
  */
 template<typename Entity, typename Allocator>
 class basic_registry {
-    using entity_traits = entt_traits<Entity>;
-    using basic_common_type = basic_sparse_set<Entity, Allocator>;
     using alloc_traits = typename std::allocator_traits<Allocator>;
+    static_assert(std::is_same_v<typename alloc_traits::value_type, Entity>, "Invalid value type");
+    using basic_common_type = basic_sparse_set<Entity, Allocator>;
+    using entity_traits = entt_traits<Entity>;
 
     template<typename Type>
     using storage_for_type = typename storage_for<Type, Entity>::type;