Sfoglia il codice sorgente

registry: rename ::any to ::any_of

Michele Caini 5 anni fa
parent
commit
0ff5c18743

+ 2 - 2
docs/md/entity.md

@@ -284,7 +284,7 @@ if(registry.has<velocity>(entity)) {
 }
 ```
 
-The `all_of` and `any` member functions may also be useful if in doubt about
+The `all_of` and `any_of` member functions may also be useful if in doubt about
 whether or not an entity has all the components in a set or any of them:
 
 ```cpp
@@ -292,7 +292,7 @@ whether or not an entity has all the components in a set or any of them:
 bool all = registry.all_of<position, velocity>(entity);
 
 // true if entity has at least one of the given components
-bool any = registry.any<position, velocity>(entity);
+bool any = registry.any_of<position, velocity>(entity);
 ```
 
 If the goal is to delete a component from an entity that owns it, the `remove`

+ 2 - 2
src/entt/entity/handle.hpp

@@ -231,14 +231,14 @@ struct basic_handle {
 
     /**
      * @brief Checks if a handle has at least one of the given components.
-     * @sa basic_registry::any
+     * @sa basic_registry::any_of
      * @tparam Component Components for which to perform the check.
      * @return True if the handle has at least one of the given components,
      * false otherwise.
      */
     template<typename... Component>
     [[nodiscard]] decltype(auto) any() const {
-        return reg->template any<Component...>(entt);
+        return reg->template any_of<Component...>(entt);
     }
 
     /**

+ 3 - 3
src/entt/entity/observer.hpp

@@ -179,7 +179,7 @@ class basic_observer {
     struct matcher_handler<matcher<type_list<Reject...>, type_list<Require...>, AnyOf>> {
         template<std::size_t Index>
         static void maybe_valid_if(basic_observer &obs, basic_registry<Entity> &reg, const Entity entt) {
-            if(reg.template all_of<Require...>(entt) && !reg.template any<Reject...>(entt)) {
+            if(reg.template all_of<Require...>(entt) && !reg.template any_of<Reject...>(entt)) {
                 if(!obs.view.contains(entt)) {
                     obs.view.emplace(entt);
                 }
@@ -217,9 +217,9 @@ class basic_observer {
         static void maybe_valid_if(basic_observer &obs, basic_registry<Entity> &reg, const Entity entt) {
             if([&reg, entt]() {
                 if constexpr(sizeof...(Ignore) == 0) {
-                    return reg.template all_of<AllOf..., Require...>(entt) && !reg.template any<NoneOf..., Reject...>(entt);
+                    return reg.template all_of<AllOf..., Require...>(entt) && !reg.template any_of<NoneOf..., Reject...>(entt);
                 } else {
-                    return reg.template all_of<AllOf..., Require...>(entt) && ((std::is_same_v<Ignore..., NoneOf> || !reg.template any<NoneOf>(entt)) && ...) && !reg.template any<Reject...>(entt);
+                    return reg.template all_of<AllOf..., Require...>(entt) && ((std::is_same_v<Ignore..., NoneOf> || !reg.template any_of<NoneOf>(entt)) && ...) && !reg.template any_of<Reject...>(entt);
                 }
             }())
             {

+ 3 - 3
src/entt/entity/registry.hpp

@@ -772,7 +772,7 @@ public:
      * false otherwise.
      */
     template<typename... Component>
-    [[nodiscard]] bool any(const entity_type entity) const {
+    [[nodiscard]] bool any_of(const entity_type entity) const {
         ENTT_ASSERT(valid(entity));
         return (all_of<Component>(entity) || ...);
     }
@@ -1481,7 +1481,7 @@ public:
     template<typename Type, typename... Args>
     Type & set(Args &&... args) {
         unset<Type>();
-        vars.push_back(entt::any{std::in_place_type<Type>, std::forward<Args>(args)...});
+        vars.push_back(any{std::in_place_type<Type>, std::forward<Args>(args)...});
         return any_cast<Type &>(vars.back());
     }
 
@@ -1582,7 +1582,7 @@ public:
     }
 
 private:
-    std::vector<entt::any> vars{};
+    std::vector<any> vars{};
     std::vector<pool_data> pools{};
     std::vector<group_data> groups{};
     std::vector<entity_type> entities{};

+ 1 - 1
test/entt/entity/poly_storage.cpp

@@ -76,7 +76,7 @@ TEST(PolyStorage, CopyEntity) {
     registry.emplace<char>(entity, 'c');
 
     ASSERT_TRUE((registry.all_of<int, char>(entity)));
-    ASSERT_FALSE((registry.any<int, char>(other)));
+    ASSERT_FALSE((registry.any_of<int, char>(other)));
 
     registry.visit(entity, [&](const auto info) {
         auto storage = registry.storage(info);

+ 7 - 7
test/entt/entity/registry.cpp

@@ -123,7 +123,7 @@ TEST(Registry, Functionalities) {
     registry.emplace<char>(e1);
 
     ASSERT_TRUE(registry.all_of<>(e0));
-    ASSERT_FALSE(registry.any<>(e1));
+    ASSERT_FALSE(registry.any_of<>(e1));
 
     ASSERT_EQ(registry.size<int>(), 1u);
     ASSERT_EQ(registry.size<char>(), 1u);
@@ -134,8 +134,8 @@ TEST(Registry, Functionalities) {
 
     ASSERT_FALSE((registry.all_of<int, char>(e0)));
     ASSERT_TRUE((registry.all_of<int, char>(e1)));
-    ASSERT_FALSE((registry.any<int, double>(e0)));
-    ASSERT_TRUE((registry.any<int, double>(e1)));
+    ASSERT_FALSE((registry.any_of<int, double>(e0)));
+    ASSERT_TRUE((registry.any_of<int, double>(e1)));
 
     ASSERT_EQ(registry.try_get<int>(e0), nullptr);
     ASSERT_NE(registry.try_get<int>(e1), nullptr);
@@ -151,8 +151,8 @@ TEST(Registry, Functionalities) {
 
     ASSERT_TRUE((registry.all_of<int, char>(e0)));
     ASSERT_FALSE((registry.all_of<int, char>(e1)));
-    ASSERT_TRUE((registry.any<int, double>(e0)));
-    ASSERT_FALSE((registry.any<int, double>(e1)));
+    ASSERT_TRUE((registry.any_of<int, double>(e0)));
+    ASSERT_FALSE((registry.any_of<int, double>(e1)));
 
     const auto e2 = registry.create();
 
@@ -1373,13 +1373,13 @@ TEST(Registry, Dependencies) {
 
     registry.remove<int>(entity);
 
-    ASSERT_FALSE((registry.any<int, double>(entity)));
+    ASSERT_FALSE((registry.any_of<int, double>(entity)));
 
     registry.on_construct<int>().disconnect<emplace_or_replace>();
     registry.on_destroy<int>().disconnect<remove>();
     registry.emplace<int>(entity);
 
-    ASSERT_TRUE((registry.any<int, double>(entity)));
+    ASSERT_TRUE((registry.any_of<int, double>(entity)));
     ASSERT_FALSE(registry.all_of<double>(entity));
 }
 

+ 1 - 1
test/example/custom_identifier.cpp

@@ -42,7 +42,7 @@ TEST(Example, CustomIdentifier) {
 
     registry.emplace<int>(entity, 42);
 
-    ASSERT_TRUE((registry.any<int, char>(entity)));
+    ASSERT_TRUE((registry.any_of<int, char>(entity)));
     ASSERT_EQ(registry.get<int>(entity), 42);
 
     registry.destroy(entity);