std::size_t is a typedef for the underlying unsigned type, and it should be able to represent any possible index / size in your program (technically this is also the result of the sizeof operator). Its base type may vary in different implementations, and since you want portability, you use std::size_t and don't care if it is unsigned long int or unsigned long long int , etc.
std::size_t does not use any function that cannot be used in any other way, it is just a convenient type alias and nothing more.
In response to editing the OP
@HoapHumanoid. Editing is not a good question for StackOverflow, as it is a matter of personal interpretation / preference. Of course, you can have only one type of numeric type or a type of fixed size, however, when you want to squeeze out as much performance from your processor that you have to have a lot, each of which is able to display a certain range, depending on the physical . Since computer architectures vary widely, each architecture will impose its own size, for example. int , long , etc. When you combine this problem with portability, then size_t occurs naturally. What else would you use in a common function, for example, is it a guarantee of the maximum possible amount of memory for each possible implementation ? Do you use int byte count? Or maybe long int ? You need to read the compiler manual, check the appropriate type, etc., and then use it. What the C ++ implementation does for you defines the appropriate type.
vsoftco
source share