Преглед изворни кода

entity: handle conversion warnings

Michele Caini пре 1 година
родитељ
комит
1fddb2c4c9
2 измењених фајлова са 5 додато и 5 уклоњено
  1. 4 4
      src/entt/entity/sparse_set.hpp
  2. 1 1
      src/entt/entity/storage.hpp

+ 4 - 4
src/entt/entity/sparse_set.hpp

@@ -73,7 +73,7 @@ struct sparse_set_iterator final {
     }
 
     [[nodiscard]] constexpr reference operator[](const difference_type value) const noexcept {
-        return (*packed)[index() - value];
+        return (*packed)[static_cast<typename Container::size_type>(index() - value)];
     }
 
     [[nodiscard]] constexpr pointer operator->() const noexcept {
@@ -190,7 +190,7 @@ class basic_sparse_set {
     }
 
     [[nodiscard]] auto to_iterator(const Entity entt) const {
-        return --(end() - index(entt));
+        return --(end() - static_cast<typename const_iterator::difference_type>(index(entt)));
     }
 
     [[nodiscard]] auto &assure_at_least(const Entity entt) {
@@ -646,7 +646,7 @@ public:
      * @return An iterator to the first entity of the sparse set.
      */
     [[nodiscard]] iterator begin() const noexcept {
-        const auto pos = static_cast<typename iterator::difference_type>(packed.size());
+        const auto pos = static_cast<typename const_iterator::difference_type>(packed.size());
         return iterator{packed, pos};
     }
 
@@ -998,7 +998,7 @@ public:
         ENTT_ASSERT((mode != deletion_policy::in_place) || (head == max_size), "Sorting with tombstones not allowed");
         ENTT_ASSERT(!(length > packed.size()), "Length exceeds the number of elements");
 
-        algo(packed.rend() - length, packed.rend(), std::move(compare), std::forward<Args>(args)...);
+        algo(packed.rend() - static_cast<typename packed_container_type::difference_type>(length), packed.rend(), std::move(compare), std::forward<Args>(args)...);
 
         for(size_type pos{}; pos < length; ++pos) {
             auto curr = pos;

+ 1 - 1
src/entt/entity/storage.hpp

@@ -560,7 +560,7 @@ public:
      * @return An iterator to the first instance of the internal array.
      */
     [[nodiscard]] const_iterator cbegin() const noexcept {
-        const auto pos = static_cast<typename iterator::difference_type>(base_type::size());
+        const auto pos = static_cast<typename const_iterator::difference_type>(base_type::size());
         return const_iterator{&payload, pos};
     }