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

entt_traits: removed the (mostly useless) difference_type alias

Michele Caini 4 лет назад
Родитель
Сommit
a0ed0c864f
4 измененных файлов с 5 добавлено и 9 удалено
  1. 1 1
      TODO
  2. 0 4
      src/entt/entity/entity.hpp
  3. 1 1
      src/entt/entity/sparse_set.hpp
  4. 3 3
      src/entt/entity/storage.hpp

+ 1 - 1
TODO

@@ -4,7 +4,7 @@
 * add examples (and credits) from @alanjfs :)
 
 WIP:
-* decouple storage iterator from allocator
+* make ::page/::offset (sparse_set/storage) publicly available, decouple storage iterator from allocator
 * fast-contains for sparse sets (low prio but nice-to-have)
 * runtime components (registry), runtime events (dispatcher/emitter), runtime context variables ...
 * runtime_view/registry, remove reference to basic_sparse_set<E>

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

@@ -40,7 +40,6 @@ template<>
 struct entt_traits<std::uint32_t> {
     using entity_type = std::uint32_t;
     using version_type = std::uint16_t;
-    using difference_type = std::int64_t;
 
     static constexpr entity_type entity_mask = 0xFFFFF;
     static constexpr entity_type version_mask = 0xFFF;
@@ -52,7 +51,6 @@ template<>
 struct entt_traits<std::uint64_t> {
     using entity_type = std::uint64_t;
     using version_type = std::uint32_t;
-    using difference_type = std::int64_t;
 
     static constexpr entity_type entity_mask = 0xFFFFFFFF;
     static constexpr entity_type version_mask = 0xFFFFFFFF;
@@ -84,8 +82,6 @@ public:
     using entity_type = typename entity_traits::entity_type;
     /*! @brief Underlying version type. */
     using version_type = typename entity_traits::version_type;
-    /*! @brief Difference type. */
-    using difference_type = typename entity_traits::difference_type;
     /*! @brief Reserved identifier. */
     static constexpr entity_type reserved = entity_traits::entity_mask | (entity_traits::version_mask << entity_traits::entity_shift);
 

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

@@ -550,7 +550,7 @@ public:
      * @return An iterator to the first entity of the sparse set.
      */
     [[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
-        const auto pos = static_cast<typename entity_traits::difference_type>(count);
+        const auto pos = static_cast<typename iterator::difference_type>(count);
         return iterator{std::addressof(packed), pos};
     }
 

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

@@ -71,7 +71,7 @@ class basic_storage: public basic_sparse_set<Entity, typename std::allocator_tra
 
     template<typename Value>
     struct storage_iterator final {
-        using difference_type = typename entity_traits::difference_type;
+        using difference_type = std::ptrdiff_t;
         using value_type = Value;
         using pointer = value_type *;
         using reference = value_type &;
@@ -510,7 +510,7 @@ public:
      * @return An iterator to the first instance of the internal array.
      */
     [[nodiscard]] const_iterator cbegin() const ENTT_NOEXCEPT {
-        const auto pos = static_cast<typename entity_traits::difference_type>(base_type::size());
+        const auto pos = static_cast<typename iterator::difference_type>(base_type::size());
         return const_iterator{std::addressof(packed), pos};
     }
 
@@ -521,7 +521,7 @@ public:
 
     /*! @copydoc begin */
     [[nodiscard]] iterator begin() ENTT_NOEXCEPT {
-        const auto pos = static_cast<typename entity_traits::difference_type>(base_type::size());
+        const auto pos = static_cast<typename iterator::difference_type>(base_type::size());
         return iterator{std::addressof(packed), pos};
     }