-
I'm wondering why entt::registry::is_valid is implemented in this way:
To my understanding, the information of entities is stored in |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Good question. They are the same, but for a very specific case. |
Beta Was this translation helpful? Give feedback.
Good question. They are the same, but for a very specific case.
When you delete an identifier, the entity remains the same while the version is increased. The new identifier is kept in the storage for reuse.
In theory, you can then construct the same identifier with the entity traits and query the storage for validity. Since the identifier is there, but is reserved for recycling, it's invalid from the point of view of the user. That is, it wasn't returned yet nor made available.
Will anyone ever do this type of query? I don't think so. However, the check you see prevents errors. You never know? 🙂