Michele Caini 7 ani în urmă
părinte
comite
0d61289bf3
2 a modificat fișierele cu 13 adăugiri și 8 ștergeri
  1. 1 1
      appveyor.yml
  2. 12 7
      src/entt/entity/sparse_set.hpp

+ 1 - 1
appveyor.yml

@@ -14,7 +14,7 @@ configuration:
 
 before_build:
   - cd %BUILD_DIR%
-  - cmake .. -DCMAKE_CXX_FLAGS=/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING -G"Visual Studio 15 2017"
+  - cmake .. -DCMAKE_CXX_FLAGS=/W1 -G"Visual Studio 15 2017"
 
 build:
   parallel: true

+ 12 - 7
src/entt/entity/sparse_set.hpp

@@ -122,7 +122,8 @@ class SparseSet<Entity> {
         }
 
         reference operator[](const difference_type value) const ENTT_NOEXCEPT {
-            return (*direct)[index-value-1];
+            const auto pos = size_type(index-value-1);
+            return (*direct)[pos];
         }
 
         bool operator==(const Iterator &other) const ENTT_NOEXCEPT {
@@ -150,7 +151,8 @@ class SparseSet<Entity> {
         }
 
         pointer operator->() const ENTT_NOEXCEPT {
-            return &(*direct)[index-1];
+            const auto pos = size_type(index-1);
+            return &(*direct)[pos];
         }
 
         inline reference operator*() const ENTT_NOEXCEPT {
@@ -422,7 +424,8 @@ public:
      */
     size_type get(const entity_type entity) const ENTT_NOEXCEPT {
         assert(has(entity));
-        return reverse[entity & traits_type::entity_mask];
+        const auto pos = size_type(entity & traits_type::entity_mask);
+        return size_type(reverse[pos]);
     }
 
     /**
@@ -463,10 +466,10 @@ public:
     virtual void destroy(const entity_type entity) {
         assert(has(entity));
         const auto back = direct.back();
-        auto &candidate = reverse[entity & traits_type::entity_mask];
+        auto &candidate = reverse[size_type(entity & traits_type::entity_mask)];
         // swapping isn't required here, we are getting rid of the last element
         reverse[back & traits_type::entity_mask] = candidate;
-        direct[candidate] = back;
+        direct[size_type(candidate)] = back;
         candidate = null;
         direct.pop_back();
     }
@@ -637,7 +640,8 @@ class SparseSet<Entity, Type>: public SparseSet<Entity> {
         }
 
         reference operator[](const difference_type value) const ENTT_NOEXCEPT {
-            return (*instances)[index-value-1];
+            const auto pos = size_type(index-value-1);
+            return (*instances)[pos];
         }
 
         bool operator==(const Iterator &other) const ENTT_NOEXCEPT {
@@ -665,7 +669,8 @@ class SparseSet<Entity, Type>: public SparseSet<Entity> {
         }
 
         pointer operator->() const ENTT_NOEXCEPT {
-            return &(*instances)[index-1];
+            const auto pos = size_type(index-1);
+            return &(*instances)[pos];
         }
 
         inline reference operator*() const ENTT_NOEXCEPT {