ソースを参照

sparse set: make vs2017 work (more or less) fine when id_type is std::uint64_t

Michele Caini 4 年 前
コミット
8cfd08b137
1 ファイル変更9 行追加9 行削除
  1. 9 9
      src/entt/entity/sparse_set.hpp

+ 9 - 9
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<size_type>(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<size_type>(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<size_type>(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<size_type>(traits_type::to_entity(ref));
         ENTT_ASSERT(packed[pos] == entt, "Invalid entity identifier");
 
         packed[pos] = std::exchange(free_list, traits_type::construct(static_cast<typename traits_type::entity_type>(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<size_type>(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<size_type>(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<size_type>(traits_type::to_entity(free_list));
             sparse[page(entt)][offset(entt)] = traits_type::construct(static_cast<typename traits_type::entity_type>(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<size_type>(traits_type::to_entity(entt));
+        const auto to = static_cast<size_type>(traits_type::to_entity(other));
 
         // basic no-leak guarantee (with invalid state) if swapping throws
         swap_at(from, to);