Browse Source

runtime_view: bool operator to test for validity

Michele Caini 2 years ago
parent
commit
53f8600ae5
1 changed files with 8 additions and 0 deletions
  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()};
     }
 
+    /**
+     * @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.
      * @param entt A valid identifier.