From 0e27d33e7ede890e7d620ccb455d3b2730287de0 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Wed, 23 Nov 2022 08:54:56 +0100 Subject: [PATCH] storage: public traits_type member type --- src/entt/entity/storage.hpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/entt/entity/storage.hpp b/src/entt/entity/storage.hpp index aee44a75e..1131fcb8b 100644 --- a/src/entt/entity/storage.hpp +++ b/src/entt/entity/storage.hpp @@ -234,16 +234,15 @@ class basic_storage: public basic_sparse_set, "Invalid value type"); using underlying_type = basic_sparse_set>; using container_type = std::vector>; - using comp_traits = component_traits; static constexpr bool is_pinned_type_v = !(std::is_move_constructible_v && std::is_move_assignable_v); [[nodiscard]] auto &element_at(const std::size_t pos) const { - return packed[pos / comp_traits::page_size][fast_mod(pos, comp_traits::page_size)]; + return packed[pos / traits_type::page_size][fast_mod(pos, traits_type::page_size)]; } auto assure_at_least(const std::size_t pos) { - const auto idx = pos / comp_traits::page_size; + const auto idx = pos / traits_type::page_size; if(!(idx < packed.size())) { auto curr = packed.size(); @@ -252,7 +251,7 @@ class basic_storage: public basic_sparse_set @@ -282,7 +281,7 @@ class basic_storage: public basic_sparse_set; /*! @brief Allocator type. */ using allocator_type = Allocator; /*! @brief Type of the objects assigned to entities. */ @@ -393,9 +394,9 @@ public: /*! @brief Constant pointer type to contained elements. */ using const_pointer = typename alloc_traits::template rebind_traits::const_pointer; /*! @brief Random access iterator type. */ - using iterator = internal::storage_iterator>; + using iterator = internal::storage_iterator>; /*! @brief Constant random access iterator type. */ - using const_iterator = internal::storage_iterator>; + using const_iterator = internal::storage_iterator>; /*! @brief Reverse iterator type. */ using reverse_iterator = std::reverse_iterator; /*! @brief Constant reverse iterator type. */ @@ -414,7 +415,7 @@ public: * @param allocator The allocator to use. */ explicit basic_storage(const allocator_type &allocator) - : base_type{type_id(), deletion_policy{comp_traits::in_place_delete}, allocator}, + : base_type{type_id(), deletion_policy{traits_type::in_place_delete}, allocator}, packed{allocator} {} /** @@ -494,7 +495,7 @@ public: * @return Capacity of the storage. */ [[nodiscard]] size_type capacity() const noexcept override { - return packed.size() * comp_traits::page_size; + return packed.size() * traits_type::page_size; } /*! @brief Requests the removal of unused capacity. */ @@ -749,11 +750,12 @@ class basic_storage; static_assert(std::is_same_v, "Invalid value type"); using underlying_type = basic_sparse_set>; - using comp_traits = component_traits; public: /*! @brief Base type. */ using base_type = underlying_type; + /*! @brief Component traits. */ + using traits_type = component_traits; /*! @brief Allocator type. */ using allocator_type = Allocator; /*! @brief Type of the objects assigned to entities. */ @@ -776,7 +778,7 @@ public: * @param allocator The allocator to use. */ explicit basic_storage(const allocator_type &allocator) - : base_type{type_id(), deletion_policy{comp_traits::in_place_delete}, allocator} {} + : base_type{type_id(), deletion_policy{traits_type::in_place_delete}, allocator} {} /** * @brief Move constructor.