My understanding of size_t is that it will be large enough to hold any (integer) value that you can expect from it. (Perhaps this is a bad explanation?)
For example, if you used something like a for loop to iterate over all the elements in a vector, size_t will usually be 64 bits long (or at least on my system) so that it can hold all possible value returns from vector.size ().
Or at least I think that's right?
Therefore, is there a reason to use A rather than B:
A: for(uint64_t i = 0; i < v.size(); ++ i)
B: for(size_t i = 0; i < v.size(); ++ i)
If I am mistaken in my explanation or you have a better explanation, please feel free to edit.
Edit: I have to add that I understand that size_t behaves like a normal unsigned integer - maybe this is wrong?
c ++ integer vector size-t
user3728501
source share