According to C++ - should you size_t with a regular array?
§ 18.2 6 The type size_t is an implementation-defined unsigned integer type that is large enough to contain the size in bytes of any object.
I don't understand why this guarantees a type size_t
to be big enough for an array index or big enough to represent the number of elements in an array.
For example:
int array[1000];
for (size_t i = 0; i < 1000; ++i) {
}
It seems unrelated to me why a "large enough number to contain the size in bytes of an object" == guarantees a type size_t
to be big enough for an array index".