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

view: stable single type view ::empty function

Michele Caini 2 лет назад
Родитель
Сommit
f54cdccd4f
2 измененных файлов с 2 добавлено и 1 удалено
  1. 1 1
      src/entt/entity/view.hpp
  2. 1 0
      test/entt/entity/view.cpp

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

@@ -683,7 +683,7 @@ public:
      * @return True if the view is empty, false otherwise.
      */
     [[nodiscard]] bool empty() const noexcept {
-        return view->empty();
+        return !view || view->empty();
     }
 
     /**

+ 1 - 0
test/entt/entity/view.cpp

@@ -77,6 +77,7 @@ TEST(SingleComponentView, InvalidView) {
     ASSERT_FALSE(view);
 
     ASSERT_EQ(view.size(), 0u);
+    ASSERT_TRUE(view.empty());
 
     entt::storage<int> storage;
     view.storage(storage);