diff --git a/src/entt/entity/sparse_set.hpp b/src/entt/entity/sparse_set.hpp index e82b89266..6a876ca61 100644 --- a/src/entt/entity/sparse_set.hpp +++ b/src/entt/entity/sparse_set.hpp @@ -164,11 +164,11 @@ class basic_sparse_set { }; [[nodiscard]] static auto page(const Entity entt) ENTT_NOEXCEPT { - return size_type{traits_type::to_entity(entt) / sparse_page}; + return static_cast(traits_type::to_entity(entt) / sparse_page); } [[nodiscard]] static auto offset(const Entity entt) ENTT_NOEXCEPT { - return size_type{traits_type::to_entity(entt) & (sparse_page - 1)}; + return static_cast(traits_type::to_entity(entt) & (sparse_page - 1)); } [[nodiscard]] auto assure_page(const std::size_t idx) { @@ -246,7 +246,7 @@ protected: */ virtual void swap_and_pop(const Entity entt, [[maybe_unused]] void *ud) { auto &ref = sparse[page(entt)][offset(entt)]; - const auto pos = size_type{traits_type::to_entity(ref)}; + const auto pos = static_cast(traits_type::to_entity(ref)); ENTT_ASSERT(packed[pos] == entt, "Invalid entity identifier"); auto &last = packed[--count]; @@ -265,7 +265,7 @@ protected: */ virtual void in_place_pop(const Entity entt, [[maybe_unused]] void *ud) { auto &ref = sparse[page(entt)][offset(entt)]; - const auto pos = size_type{traits_type::to_entity(ref)}; + const auto pos = static_cast(traits_type::to_entity(ref)); ENTT_ASSERT(packed[pos] == entt, "Invalid entity identifier"); packed[pos] = std::exchange(free_list, traits_type::construct(static_cast(pos))); @@ -367,7 +367,7 @@ public: * @return The next slot available for insertion. */ [[nodiscard]] size_type slot() const ENTT_NOEXCEPT { - return free_list == null ? count : size_type{traits_type::to_entity(free_list)}; + return free_list == null ? count : static_cast(traits_type::to_entity(free_list)); } /** @@ -533,7 +533,7 @@ public: */ [[nodiscard]] size_type index(const entity_type entt) const ENTT_NOEXCEPT { ENTT_ASSERT(contains(entt), "Set does not contain entity"); - return size_type{traits_type::to_entity(sparse[page(entt)][offset(entt)])}; + return static_cast(traits_type::to_entity(sparse[page(entt)][offset(entt)])); } /** @@ -593,7 +593,7 @@ public: return emplace_back(entt); } else { ENTT_ASSERT(!contains(entt), "Set already contains entity"); - const auto pos = size_type{traits_type::to_entity(free_list)}; + const auto pos = static_cast(traits_type::to_entity(free_list)); sparse[page(entt)][offset(entt)] = traits_type::construct(static_cast(pos)); free_list = std::exchange(packed[pos], entt); return pos; @@ -724,8 +724,8 @@ public: auto &entt = sparse[page(lhs)][offset(lhs)]; auto &other = sparse[page(rhs)][offset(rhs)]; - const auto from = size_type{traits_type::to_entity(entt)}; - const auto to = size_type{traits_type::to_entity(other)}; + const auto from = static_cast(traits_type::to_entity(entt)); + const auto to = static_cast(traits_type::to_entity(other)); // basic no-leak guarantee (with invalid state) if swapping throws swap_at(from, to);