Parcourir la source

handle: explicit iterable type

Michele Caini il y a 2 ans
Parent
commit
02836f1f43
1 fichiers modifiés avec 5 ajouts et 4 suppressions
  1. 5 4
      src/entt/entity/handle.hpp

+ 5 - 4
src/entt/entity/handle.hpp

@@ -104,6 +104,8 @@ public:
     using version_type = typename registry_type::version_type;
     using version_type = typename registry_type::version_type;
     /*! @brief Unsigned integer type. */
     /*! @brief Unsigned integer type. */
     using size_type = typename registry_type::size_type;
     using size_type = typename registry_type::size_type;
+    /*! @brief Iterable handle type. */
+    using iterable = iterable_adaptor<internal::handle_storage_iterator<typename decltype(std::declval<registry_type>().storage())::iterator>>;
 
 
     /*! @brief Constructs an invalid handle. */
     /*! @brief Constructs an invalid handle. */
     basic_handle() noexcept
     basic_handle() noexcept
@@ -129,10 +131,9 @@ public:
      *
      *
      * @return An iterable object to use to _visit_ the handle.
      * @return An iterable object to use to _visit_ the handle.
      */
      */
-    [[nodiscard]] auto storage() const noexcept {
-        auto iterable = owner->storage();
-        using iterator_type = internal::handle_storage_iterator<typename decltype(iterable)::iterator>;
-        return iterable_adaptor{iterator_type{entt, iterable.begin(), iterable.end()}, iterator_type{entt, iterable.end(), iterable.end()}};
+    [[nodiscard]] iterable storage() const noexcept {
+        auto underlying = owner->storage();
+        return iterable{{entt, underlying.begin(), underlying.end()}, {entt, underlying.end(), underlying.end()}};
     }
     }
 
 
     /**
     /**