Abuse entt::internal::type_index::next() #1158
-
Hello! I (think I) need to create unique type ids for storages at runtime, in order for have some private storage to use in dynamically created objects in my program. I could use arrays of hashed strings as a workaround, but that would not really match the requirement. Then I found entt::internal::type_index::next(), which would do the job, if calling it doesn't break anything, e.g. the need for sequential IDs for real types. But since no new type will appear at runtime, I guess that would still be guaranteed. Are there any suggestions how I could achieve this less criminal? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
The core family class is what you're looking for probably? |
Beta Was this translation helpful? Give feedback.
Yeah, exactly. You can still check if a storage exists for a given id though. Not a big deal.
Out of curiosity, is there a particular reason for which you cannot use a plain integer that you
++
as needed?If you register all known storage types from the beginning, the generator only need to check if the id is already in use in the registry and
++
again eventually until it finds the next free one.