C++ Logo

std-discussion

Advanced search

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

From: Lyberta <lyberta_at_[hidden]>
Date: Sat, 09 Nov 2019 10:30:00 +0000
Wilhelm Meier via Std-Discussion:
>> Of course, bigger problem is that CHAR_BIT can be more than 8.
>
> I dont't see the point here. Can you elaborate on that?

That means that generally reasoning about sizes of types is difficult.

What if CHAR_BIT is 10?

Then both Size < 256 and Size < 65536 don't make sense as now all the
numbers derived from number of bits in a byte are different.

> I size_t is unsigned long long int, what then will be difference_type?

std::size_t is tied to std::ptrdiff_t. So if std::size_t is unsigned
long long int then std::ptrdiff_t is long long int.

>
>> Also, unsigned sizes just don't work given the rules of the language
>> when it comes to arithmetic. We now have std::ssize to get signed sizes
>> of containers and views.
>
> in C++20?
>

Yes.


Received on 2019-11-09 04:33:09