C++ Logo

std-discussion

Advanced search

Why is size_type in std::array an alias for size_t?

From: Wilhelm Meier <wilhelm.meier_at_[hidden]>
Date: Fri, 8 Nov 2019 07:46:22 +0100
Hello all,

the member type size_type is an alias for size_t in std::array:

https://en.cppreference.com/w/cpp/container/array

The member type size_type in std::vector is an unspecified unsigned
integer type:

https://en.cppreference.com/w/cpp/container/vector

I wonder, if this is intentional, since std::array could declare the
size_type depending on the actual size of the array, e.g. an
implementation could declare size_type an alias to uint8_t if the size
of the array is less than 256 or uint16_t if the size of the array is
less than 65536.

Is this a documentation issue?

Thanks,
 Wilhelm

Received on 2019-11-08 00:48:43