C++ Logo

std-discussion

Advanced search

Re: Rationale for return type of the non-array version of std::ssize()

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 11 May 2020 07:30:10 -0700
On Monday, 11 May 2020 03:56:18 PDT Gennaro Prota wrote:
> > Or on some exotic platform with small size_t and ptrdiff_t.. ptrdiff_t is
> > not required to work for any two arbitrary pointers, only those of one
> > memory block. [...]
>
> Thanks, and sorry for the late reply. OK, so I think the next question
> is: why not just returning std::make_signed_t< decltype( c.size() ) >?

Same answer: size_t may not be big enough for this particular container.
size_t only needs to be big enough to hold the biggest object in memory.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel System Software Products

Received on 2020-05-11 09:33:26