Let's say I want to define size_t:
size_t is a typedef/type alias for unsigned long long on 64bit systems and for unsigned int on 32bit systems.
Now we know that sizeof(void*) will produce 8 on 64bit and 4 on 32bit systems.
using size_t = std::conditional_t<sizeof(void*) == 8, unsigned long long, unsigned int>;
My question is: Is this safe to do? I would appreciate if someone with more knowledge about operating systems and such share if this could cause cross-compatibility issues on different operating systems! Thanks!
Aucun commentaire:
Enregistrer un commentaire