Short containment numbers too. Like a signed char.
But none of these types can be large enough to represent the sizes of any rows.
string::size_type guarantees exactly that. This is a type that is large enough to represent the size of the string, regardless of how large the string is.
For a simple example of why this is necessary, consider 64-bit platforms. The int, as a rule, is still 32 bits on them, but you have much more 2 ^ 32 bytes of memory.
So, if an (signed) int was used, you could not create strings larger than 2 ^ 31 characters. size_type will be a 64-bit value on these platforms, so it can represent large strings without problems.
jalf Jul 25 '09 at 3:06 2009-07-25 03:06
source share