C++ Logo


Advanced search

Subject: Re: Rationale for return type of the non-array version of std::ssize()
From: Gennaro Prota (gennaro.prota_at_[hidden])
Date: 2020-05-11 05:56:18

On Thu, Apr 30, 2020 at 2:56 AM Thiago Macieira via Std-Discussion
<std-discussion_at_[hidden]> wrote:
> On Tuesday, 28 April 2020 09:42:17 PDT Bo Persson via Std-Discussion wrote:
> > Unless it is a wider type. It could be that ptrdiff_t is int and some
> > container's size() function returns unsigned long long. It just *could*.
> That is a distinct possibility if the container is not of objects in memory.
> Examples: files in the filesystem, objects in an object store database,
> database entries, etc. Or even simpler: bytes in a file.
> 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() ) >?

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

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups