Преглед изворни кода

runtime_view: bool operator to test for validity

Michele Caini пре 2 година
родитељ
комит
53f8600ae5
1 измењених фајлова са 8 додато и 0 уклоњено
  1. 8 0
      src/entt/entity/runtime_view.hpp

+ 8 - 0
src/entt/entity/runtime_view.hpp

@@ -261,6 +261,14 @@ public:
         return pools.empty() ? iterator{} : iterator{pools, filter, pools[0]->end()};
         return pools.empty() ? iterator{} : iterator{pools, filter, pools[0]->end()};
     }
     }
 
 
+    /**
+     * @brief Checks whether a view is initialized or not.
+     * @return True if the view is initialized, false otherwise.
+     */
+    [[nodiscard]] explicit operator bool() const noexcept {
+        return !(pools.empty() && filter.empty());
+    }
+
     /**
     /**
      * @brief Checks if a view contains an entity.
      * @brief Checks if a view contains an entity.
      * @param entt A valid identifier.
      * @param entt A valid identifier.