I sometimes throw pointers to integers when they somehow have to be part of the hash. In addition, I throw them into integers to execute some bit bits with them under certain implementations, where it is guaranteed that the pointers always leave one or two spare bits, where I can encode the AVL or RB tree information in the left / right pointers instead having to have an extra member. But this is all so implementation specific that I recommend that you never think of it as any common solution. I also heard that sometimes hazard labels can be implemented with such a thing.
In some situations, I need a unique identifier for each object that I pass, for example, servers as a request identifier. Depending on the context, when I need to save some memory, and it's worth it, I use the address of my object as such an identifier and usually should give it to an integer.
When working with embedded systems (for example, in canonical cameras, see chdk) magic additions are often present, therefore, (void*)0xFFBC5235 or the like is also often found there.
change
Just stumbled (in my opinion) over pthread_self() , which returns pthread_t, which is usually a typedef for an unsigned integer. Internally, although it is a pointer to some thread structure representing the thread in question. In general, it can be used elsewhere for an opaque descriptor.
PlasmaHH Aug 22 2018-11-11T00: 00Z
source share