Procházet zdrojové kódy

static registry::entity/version (close #223)

Michele Caini před 7 roky
rodič
revize
9f5f4b9c91

+ 4 - 4
docs/md/entity.md

@@ -192,8 +192,8 @@ When an entity is destroyed, the registry can freely reuse it internally with a
 slightly different identifier. In particular, the version of an entity is
 increased each and every time it's discarded.<br/>
 In case entity identifiers are stored around, the registry offers all the
-functionalities required to test them and get out of the them all the
-information they carry:
+functionalities required to test them and to get out of them the information
+they carry:
 
 ```cpp
 // returns true if the entity is still valid, false otherwise
@@ -475,8 +475,8 @@ In fact, there are two functions that respond to slightly different needs:
   Or by accessing their entities:
 
   ```cpp
-  registry.sort<renderable>([&registry](const entt::entity lhs, const entt::entity rhs) {
-      return registry.entity(lhs) < registry.entity(rhs);
+  registry.sort<renderable>([](const entt::entity lhs, const entt::entity rhs) {
+      return entt::registry::entity(lhs) < entt::registry::entity(rhs);
   });
   ```
 

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

@@ -597,7 +597,7 @@ public:
      * @param entity An entity identifier, either valid or not.
      * @return The entity identifier without the version.
      */
-    entity_type entity(const entity_type entity) const ENTT_NOEXCEPT {
+    static entity_type entity(const entity_type entity) ENTT_NOEXCEPT {
         return entity & traits_type::entity_mask;
     }
 
@@ -606,7 +606,7 @@ public:
      * @param entity An entity identifier, either valid or not.
      * @return The version stored along with the given entity identifier.
      */
-    version_type version(const entity_type entity) const ENTT_NOEXCEPT {
+    static version_type version(const entity_type entity) ENTT_NOEXCEPT {
         return version_type(entity >> traits_type::entity_shift);
     }
 

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

@@ -261,8 +261,8 @@ TEST(Registry, Identifiers) {
     const auto post = registry.create();
 
     ASSERT_NE(pre, post);
-    ASSERT_EQ(registry.entity(pre), registry.entity(post));
-    ASSERT_NE(registry.version(pre), registry.version(post));
+    ASSERT_EQ(entt::registry::entity(pre), entt::registry::entity(post));
+    ASSERT_NE(entt::registry::version(pre), entt::registry::version(post));
     ASSERT_NE(registry.version(pre), registry.current(pre));
     ASSERT_EQ(registry.version(post), registry.current(post));
 }