Răsfoiți Sursa

added empty<Comp> to the registry

Michele Caini 9 ani în urmă
părinte
comite
129b3f1830
2 a modificat fișierele cu 11 adăugiri și 0 ștergeri
  1. 5 0
      src/registry.hpp
  2. 6 0
      test/registry.cpp

+ 5 - 0
src/registry.hpp

@@ -256,6 +256,11 @@ public:
         return available.size() == count;
     }
 
+    template<typename Comp>
+    bool empty() const noexcept {
+        return pool.template empty<Comp>();
+    }
+
     entity_type create() noexcept {
         entity_type entity;
 

+ 6 - 0
test/registry.cpp

@@ -10,9 +10,15 @@ TEST(DefaultRegistry, Functionalities) {
     ASSERT_EQ(registry.capacity(), registry_type::size_type{0});
     ASSERT_TRUE(registry.empty());
 
+    ASSERT_TRUE(registry.empty<int>());
+    ASSERT_TRUE(registry.empty<char>());
+
     registry_type::entity_type e1 = registry.create();
     registry_type::entity_type e2 = registry.create<int, char>();
 
+    ASSERT_FALSE(registry.empty<int>());
+    ASSERT_FALSE(registry.empty<char>());
+
     ASSERT_NE(e1, e2);
 
     ASSERT_FALSE(registry.has<int>(e1));