Quellcode durchsuchen

sparse_set: also support (in theory) fancy pointers

Michele Caini vor 4 Jahren
Ursprung
Commit
c6d3714e6f
1 geänderte Dateien mit 3 neuen und 3 gelöschten Zeilen
  1. 3 3
      src/entt/entity/sparse_set.hpp

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

@@ -180,7 +180,7 @@ class basic_sparse_set {
     using sparse_container_type = std::vector<typename alloc_traits::pointer, typename alloc_traits::template rebind_alloc<typename alloc_traits::pointer>>;
     using packed_container_type = std::vector<Entity, alloc>;
 
-    [[nodiscard]] auto *sparse_ptr(const Entity entt) const {
+    [[nodiscard]] auto sparse_ptr(const Entity entt) const {
         const auto pos = static_cast<size_type>(entity_traits::to_entity(entt));
         const auto page = pos / entity_traits::page_size;
         return (page < sparse.size() && sparse[page]) ? (sparse[page] + fast_mod(pos, entity_traits::page_size)) : nullptr;
@@ -580,7 +580,7 @@ public:
      * @return True if the sparse set contains the entity, false otherwise.
      */
     [[nodiscard]] bool contains(const entity_type entt) const ENTT_NOEXCEPT {
-        const auto *elem = sparse_ptr(entt);
+        const auto elem = sparse_ptr(entt);
         constexpr auto cap = entity_traits::to_entity(null);
         // testing versions permits to avoid accessing the packed array
         return elem && (((~cap & entity_traits::to_integral(entt)) ^ entity_traits::to_integral(*elem)) < cap);
@@ -593,7 +593,7 @@ public:
      * version otherwise.
      */
     [[nodiscard]] version_type current(const entity_type entt) const {
-        const auto *elem = sparse_ptr(entt);
+        const auto elem = sparse_ptr(entt);
         constexpr auto fallback = entity_traits::to_version(tombstone);
         return elem ? entity_traits::to_version(*elem) : fallback;
     }