You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] @typeInfo of a type with a unique identifier #5459
Currently, there is no way to key a HashMap with a type to make a lookup table. It would be handy if we could get at a unique value to use for this use case: @typeInfo(T).id. If @typeInfo(T).id were unique to each type it would provide the perfect key for a type lookup table.
The current workaround is to use a StringHashMap keyed off of @typeName(T) with the values being auto-incremented ints.
Activity
mmstick commentedon Jun 3, 2021
This would be instrumental to creating an ECS library in Zig
ikskuh commentedon Jun 3, 2021
There's a workaround that takes up 1 byte of memory per type:
But i'd prefer to have proper
@typeIdbuiltin or a field in@typeInfothat solves this use casemmstick commentedon Jun 3, 2021
Awesome. Now I can at least complete my ECS
Parallel-Paradox commentedon Aug 22, 2023
Change @ptrToInt into @intFromPtr after 0.11.0