Просмотр исходного кода

core: handle conversion warnings

Michele Caini 1 год назад
Родитель
Сommit
65b2e5c671
1 измененных файлов с 4 добавлено и 2 удалено
  1. 4 2
      src/entt/core/algorithm.hpp

+ 4 - 2
src/entt/core/algorithm.hpp

@@ -100,6 +100,7 @@ struct radix_sort {
             constexpr auto passes = N / Bit;
 
             using value_type = typename std::iterator_traits<It>::value_type;
+            using difference_type = typename std::iterator_traits<It>::difference_type;
             std::vector<value_type> aux(static_cast<std::size_t>(std::distance(first, last)));
 
             auto part = [getter = std::move(getter)](auto from, auto to, auto out, auto start) {
@@ -121,11 +122,12 @@ struct radix_sort {
                 }
 
                 for(auto it = from; it != to; ++it) {
-                    out[index[(getter(*it) >> start) & mask]++] = std::move(*it);
+                    const auto pos = index[(getter(*it) >> start) & mask]++;
+                    out[static_cast<difference_type>(pos)] = std::move(*it);
                 }
             };
 
-            for(std::size_t pass = 0; pass < (passes & ~1); pass += 2) {
+            for(std::size_t pass = 0; pass < (passes & ~1u); pass += 2) {
                 part(first, last, aux.begin(), pass * Bit);
                 part(aux.begin(), aux.end(), first, (pass + 1) * Bit);
             }