Browse Source

storage_type[_t]/storage_for[_t]: allocator support

Michele Caini 3 years ago
parent
commit
17f47fbc92
2 changed files with 9 additions and 6 deletions
  1. 3 2
      src/entt/entity/fwd.hpp
  2. 6 4
      src/entt/entity/storage.hpp

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

@@ -2,6 +2,7 @@
 #define ENTT_ENTITY_FWD_HPP
 
 #include <memory>
+#include <type_traits>
 #include "../core/fwd.hpp"
 #include "../core/type_traits.hpp"
 
@@ -16,10 +17,10 @@ class basic_sparse_set;
 template<typename Type, typename = entity, typename = std::allocator<Type>, typename = void>
 class basic_storage;
 
-template<typename, typename = entity, typename = void>
+template<typename Type, typename = entity, typename = std::allocator<Type>, typename = void>
 struct storage_type;
 
-template<typename, typename = entity>
+template<typename Type, typename = entity, typename = std::allocator<std::remove_const_t<Type>>>
 struct storage_for;
 
 template<typename Type>

+ 6 - 4
src/entt/entity/storage.hpp

@@ -902,11 +902,12 @@ public:
  * @brief Provides a common way to define storage types.
  * @tparam Type Storage value type.
  * @tparam Entity A valid entity type (see entt_traits for more details).
+ * @tparam Allocator Type of allocator used to manage memory and elements.
  */
-template<typename Type, typename Entity, typename>
+template<typename Type, typename Entity, typename Allocator, typename>
 struct storage_type {
     /*! @brief Type-to-storage conversion result. */
-    using type = sigh_storage_mixin<basic_storage<Type, Entity>>;
+    using type = sigh_storage_mixin<basic_storage<Type, Entity, Allocator>>;
 };
 
 /**
@@ -920,11 +921,12 @@ using storage_type_t = typename storage_type<Args...>::type;
  * Type-to-storage conversion utility that preserves constness.
  * @tparam Type Storage value type, eventually const.
  * @tparam Entity A valid entity type (see entt_traits for more details).
+ * @tparam Allocator Type of allocator used to manage memory and elements.
  */
-template<typename Type, typename Entity>
+template<typename Type, typename Entity, typename Allocator>
 struct storage_for {
     /*! @brief Type-to-storage conversion result. */
-    using type = constness_as_t<storage_type_t<std::remove_const_t<Type>, Entity>, Type>;
+    using type = constness_as_t<storage_type_t<std::remove_const_t<Type>, Entity, Allocator>, Type>;
 };
 
 /**