template<xiiUInt32 InstanceIndexBits, xiiUInt32 GenerationBits>
struct xiiGenericId< InstanceIndexBits, GenerationBits >
A compact generational identifier that combines an instance index and a generation counter. A generational identifier uniquely identifies an instance within an indexed collection while providing a mechanism for detecting stale references when instance indices are reused.
The identifier consists of two components:
- Instance Index: Identifies the slot occupied by an instance within a collection.
- Generation: Distinguishes successive instances that occupy the same slot.
When an instance is removed, its index may be reused for a new instance. By incrementing the generation counter associated with that slot, previously issued identifiers can be distinguished from identifiers referring to the newly allocated instance.
Both components are packed into a single integral storage type, allowing the identifier to be stored, copied, and compared efficiently.
- Template Parameters
-
| InstanceIndexBits | Number of bits reserved for the instance index. |
| GenerationBits | Number of bits reserved for the generation counter. |
- Note
- The generation counter provides stale-identifier detection only when the owning collection maintains and validates generation values. Generation counter wraparound may eventually cause an old identifier to become valid again.
-
The bit-field layout is implementation-defined. The packed representation should not be assumed to have a portable binary layout across different compilers or platforms.
- See also
- XII_DECLARE_ID_TYPE