C++ Logo

std-discussion

Advanced search

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

From: Gennaro Prota <gennaro.prota_at_[hidden]>
Date: Tue, 12 May 2020 10:09:11 +0200
On Mon, May 11, 2020 at 4:30 PM Thiago Macieira <thiago_at_[hidden]> wrote:
>
> 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.

Yes, so the container's size() member won't return a size_t.

--
--
.:: Gennaro Prota ::.
.:: https://about.me/gennaro.prota ::.

Received on 2020-05-12 03:12:53