Using a float would be horrible, as that would be the wrong use of floating point types, plus type advancement would mean that multiplying the size of something would take place in the floating point!
Using a int also be horrible, since the int specification is intentionally freely defined by the C ++ standard. (It can be like 16 bits).
But the size_t type is guaranteed to adequately display the size of almost any size and, of course, the size of the containers in the C ++ standard library. Its specific details depend on the specific platform and architecture. The fact that this is an unsigned type is the subject of much discussion. (I personally think that it was a mistake to make it unsigned , as this can ruin the code using relational operators and introduce fatal errors that are difficult to detect).
source share