Ver Fonte

sparse set: avoid C-arrays

Michele Caini há 1 ano atrás
pai
commit
7db890ba15
1 ficheiros alterados com 3 adições e 2 exclusões
  1. 3 2
      src/entt/entity/sparse_set.hpp

+ 3 - 2
src/entt/entity/sparse_set.hpp

@@ -1,6 +1,7 @@
 #ifndef ENTT_ENTITY_SPARSE_SET_HPP
 #define ENTT_ENTITY_SPARSE_SET_HPP
 
+#include <array>
 #include <cstddef>
 #include <iterator>
 #include <memory>
@@ -997,7 +998,7 @@ public:
      */
     template<typename Compare, typename Sort = std_sort, typename... Args>
     void sort(Compare compare, Sort algo = Sort{}, Args &&...args) {
-        const size_type len[]{packed.size(), head};
+        const std::array len{packed.size(), head};
         sort_n(len[mode == deletion_policy::swap_only], std::move(compare), std::move(algo), std::forward<Args>(args)...);
     }
 
@@ -1017,7 +1018,7 @@ public:
     template<typename It>
     iterator sort_as(It first, It last) {
         ENTT_ASSERT((mode != deletion_policy::in_place) || (head == max_size), "Sorting with tombstones not allowed");
-        const size_type len[]{packed.size(), head};
+        const std::array len{packed.size(), head};
         auto it = end() - static_cast<typename iterator::difference_type>(len[mode == deletion_policy::swap_only]);
 
         for(const auto other = end(); (it != other) && (first != last); ++first) {